Microsoft graph API to find only parent sites and skip subsites

Akash Asthana 0 Reputation points Microsoft Employee
2024-09-30T18:45:07.2066667+00:00

Hi,
I am looking for a way to find only parent sites in a tenant.

There exist an API in Microsoft Graph which can get me list of all the sites( and subsites) if I don't pass any search keyword
https://graph.microsoft.com/v1.0/sites?search=

But there is no property in the response which can help in deducing which one is a parent site and which one is a subsite.

We have a requirement to know all the parent sites in the tenant.
Is there a property in the response or api query filter we can use to get only the parent sites and drop the subsites?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,019 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,979 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 24,716 Reputation points Microsoft Vendor
    2024-10-01T07:26:46.03+00:00

    Hi @Akash Asthana ,

    You can call the /sites endpoint to get all available parent sites in your organization. Note that this endpoint is only available in the application context.

    User's image

    Result:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.