I'm looking for a way to get all the site collections for a particular tenant through API.

The URL that lists all site collections is


How can I get this info using a REST API endpoint?

Update 1:

This API call


Doesn't work for me.

I get the following error (500 Internal Server Error)

"error": {
    "code": "-1, Microsoft.Office.Server.Search.REST.SearchServiceException",
    "message": {
        "lang": "en-US",
        "value": "An unknown error occurred."


FYI: I am using Client Credentials Flow to get the access token. App level permissions list doesn't have any permission to Search like in Delegated permissions. Could that be the issue?


2 Answers 2


It is available in Powershell too, if you have downloaded the SharePoint Online module. Not sure what or how you want to use the data, but it is available that way.


Get-SPOSite -Limit All

You can also use a search query to look at all STS_Site content classes.

  • The search query doesn't work for me. I get >>> { "error": { "code": "-1, Microsoft.Office.Server.Search.REST.SearchServiceException", "message": { "lang": "en-US", "value": "An unknown error occurred." } } } >>>> URL I hit >>> https://{tenantName}-admin.sharepoint.com/_api/search/query?querytext='contentclass:sts_site' >>> The only thing I can think of is that I use client credentials flow to get access token. Is that the issue? Commented Jul 24, 2015 at 5:18
  • Updated my question. Commented Jul 24, 2015 at 11:12
  • STS_Site option doesn't return the entire list. I am the owner of some and I don't get them in response (I got this search call working using Authorization code grant flow) Commented Aug 1, 2015 at 10:53
  • STS_Site returns top level collections that the current user has access to, you'd need to do some sort of impersonated call if you wanted to retrieve everything. Commented Aug 3, 2015 at 0:45
  • Correct on the STS_Site part, but the problem is that not all Top level sites are returned in that call. I have a list of Top level sites >>> https://<tenantName>-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx >>> But the call returns only 2-3 of these (top level sites) even though the user I am doing the call with has access to ALL of them (he's the site admin/owner for all) If I know the top level sites, getting inner/subsites is easy. Commented Aug 3, 2015 at 4:32

I found the following link and an older StackExchange question pointing out that you can do it using CSOM but you can't do it with REST API.

  • That doesn't work for me. I am using Client Credentials Flow to get access token. Is that the issue? URL I hit >>> https://{tenantName}-admin.sharepoint.com/_api/search/query?querytext='.... Commented Jul 24, 2015 at 5:16
  • Updated my question. Commented Jul 24, 2015 at 11:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.