Graph API finally adds support for LISTing /teams

Microsoft Teams have been around for years now, and so has the Graph API. Yet, until now there was no “direct” way of listing all the Teams within a given organization. Instead, we had to resort to workarounds, such as listing all the Microsoft 365 Groups and filtering them based on the value of the resourceProvisioningOptions property. Well, no more. Microsoft has finally introduced support for the LIST operation, using the /teams endpoint. In other words, the following query is now possible and will return the list of all teams within the organization:

GET https://graph.microsoft.com/beta/teams

The good old “workaround” still works:

GET https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')

and you can expect to get the same number of entries. I also need to make a small correction to the statement above, as returning “all” teams in a large organization will likely require multiple “pages” of output. Luckily, the method support the $top and $skiptopen operators, which will help you achieve that.

Speaking of output, you will notice that currently only few properties are populated. Those include: id, displayName, description, and nothing else. While dozen other properties are returned in the output, you will find their values to be all ‘null’. This has been noted as a known issue over at the documentation page, although we have no information as to whether Microsoft plans to address this in the future, or we will have to query individual teams to get those values. In all fairness, this matches the current behavior of the “workaround” anyway, as the group properties returned by it are of course quite different from the teams-specific properties, so using either solution you have to query each team individually if you need those details.

Another thing to have in mind is that the new method has its own permission requirements, namely you need one of the following: Team.ReadBasic.All, TeamSettings.Read.All, TeamSettings.ReadWrite.All. And, as an added bonus, application permissions are supported out of the box! On a slightly related tangent, over the past few weeks bunch of other teams-related Graph API endpoints have finally received support for application permissions, so yay!

The last point to make here is that this method is currently in beta, so use with care. Oh, and one other thing – the output by default includes the count of teams objects, without having to add the $count operator or the consistencyLevel header.

This entry was posted in Azure AD, Microsoft 365, Microsoft Teams, Office 365. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.