Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

How to retrieve a list of all schemas from Sanity content lake?

1 replyLast updated: Nov 29, 2025

Hey folks, another question but maybe more simple. Can I retrieve a list of all schemas I have on the content lake? I can't find a way to do that
AI Update

Yes! You can retrieve a list of all unique document types (_type values) from your Content Lake using GROQ. Here's how:

*[]._type

This returns an array of all _type values from all documents. However, you'll likely want to get just the unique types without duplicates:

array::unique(*[]._type)

This uses the array::unique() function to filter out duplicate _type values, giving you a clean list of all schema types that actually exist in your dataset.

Additional options

If you want more information about each type, you could count how many documents of each type exist:

{
  "types": array::unique(*[]._type)
}

Or create a more detailed breakdown by grouping and counting. While GROQ doesn't have a built-in GROUP BY, you can work around it:

array::unique(*[]._type) | order(@) {
  "type": @,
  "count": count(*[_type == ^])
}

Where to run these queries

You can test these queries in:

Important notes

The array::unique() function is perfect for this use case - it removes duplicates from arrays, which is exactly what you need when getting all unique _type values from your documents!

Show original thread
1 reply

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions