How to get root contents?

I am building a file picker, I want to list everything that’s in the “root”. I thought I’d just query for the spaces, but there can be pages with no ancestors too, how to query for all of those in one api call?

While querying spaces gives you top-level pages, some pages might not have ancestors. To get all root-level content in a single API call, you can use the Content API with a CQL query like:

cql=type=page AND ancestor=null

This will return all pages that don’t have a parent, meaning they exist at the root level. If you also need spaces, you can fetch them separately using /rest/api/space. Unfortunately, there’s no single API call that retrieves both spaces and root pages, so combining these two queries is the most efficient approach. Let me know if you need more details or help.