How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Is it possible to check for how many unique attributes are being used in a specific sanity database?

2 repliesLast updated: Dec 1, 2025

Hello there, I have a question about unique attributes. Is it possible to check for how many unique attributes are being used in a specific sanity database? And if so, how do I check the number of unique attributes for a project?
AI Update

Yes, you can check how many unique attributes are being used in your Sanity project! Here's what you need to know:

Checking Your Current Attribute Count

You can monitor your project's unique attribute count by accessing the stats API endpoint:

<projectId>.api.sanity.io/v1/data/stats/<datasetName>

Replace <projectId> with your actual project ID and <datasetName> with your dataset name (typically "production"). For example: abc123.api.sanity.io/v1/data/stats/production

In the JSON response, look for fields.count.value - this shows your current unique attribute count. You'll also see fields.count.limit which shows your plan's maximum.

Understanding Attribute Limits by Plan

The attribute limits vary based on your Sanity plan:

There are also per-document limits:

What Counts as a Unique Attribute?

An attribute is defined as a unique combination of attribute path and datatype. Think of them as the different paths through your content structure:

{
  "foo": [
    {
      "bar": "text",
      "baz": "more text"
    }
  ]
}

This counts as 5 unique attributes:

Important: Attributes are only counted when they hold actual content. Just changing your schema definitions won't affect the count - you need to actually add or remove content using Studio or the API.

Using GROQ to Explore Your Data

While GROQ doesn't have a built-in "count unique attributes" function, you can use the Vision plugin to query and explore your content structure. The stats endpoint mentioned above is the official way to get the exact count.

Best Practices to Stay Under the Limit

If you're approaching your limit, consider:

The stats API is your best friend for monitoring this - check it periodically during development, especially if you're building complex, nested content models!

Show original thread
2 replies

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