Check if a given SharePoint site belongs to Teams (SharePoint REST API, or CSOM)

Pablo Glomby 186 Reputation points

I cannot use Microsoft Graph (else it would be easy) because I cannot get the Graph Token (I use the SharePointOnlineCredentials with username/password).
So all I can use is CSOM and the REST API.

Right now I get the frequent sites using this REST API:

It returns the recent sharepoint sites including those belonging to Teams. I need to know if a given site belongs to Teams or not.
I have read that using the WebTemplate value would be enough (if it is Group) but I discovered that I can manually create a SP site and it can hold this value.

Is there a reliable way to know if a given site is used in Teams?

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,211 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,029 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,594 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Trevor Seward 11,696 Reputation points

    Using a username and password is considered insecure and you should switch to Client ID + Certificate or less preferably, Secret. The Graph API is how you need to pull this info.

    0 comments No comments

  2. MichaelHan-MSFT 18,021 Reputation points

    Hi @Pablo Glomby ,

    Using SharePoint Rest Api or CSOM, we cannot check if the site is used in Teams. As you said, we can only get the WebTemplate value. But that's not enough.

    As far as I know, when a site is used in Teams, the assosiated M365 group will have Teams connected. You can identify go to admin center> Groups>there you can see Teams status and symbol to identify that SharePoint site is used in Microsoft Teams. See image below for your reference.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.