Do different document types with same field name count as separate attributes?

3 replies
Last updated: Oct 4, 2024
Hello all,w.r.t the Sanity attribute limit.

https://www.sanity.io/docs/attribute-limit
I understand that it's based on unique paths that hold content.
But do different document types duplicate this?

i.e. say I have two document types
page
and
post

They both have a
body
field which are both a string.
Would that field count as 2 attributes? or 1 attribute?

Thanks
🙂
AI Update

Great question! The attribute limit is based on unique paths across your entire dataset, not per document type. So to answer your question directly:

The body field would count as 2 attributes because they exist at different paths in your content structure:

  • page.body (a string)
  • post.body (a string)

Even though both fields have the same name and are the same type (string), they're at different locations in your content hierarchy, so Sanity counts them as separate unique paths.

How attributes are counted

According to the attribute limit documentation, an attribute is defined as a unique combination of path and datatype. Think of it as all the different routes through your content structure.

For example, if you have:

page {
  body: string
  title: string
}

post {
  body: string
  author: string
}

This creates 4 attributes:

  1. page.body → string
  2. page.title → string
  3. post.body → string
  4. post.author → string

Important things to know

  • Paths only count when they hold actual content. Just defining fields in your schema doesn't increase the count - you need to actually create documents with content in those fields.

  • Each unique path counts once, no matter how many documents use it. So if you have 100 page documents, page.body still only counts as 1 attribute.

  • The limits vary by plan:

    • Free: 2,000 attributes
    • Growth: 10,000 attributes
    • Enterprise: Custom limit

You can check your current attribute count by visiting: https://<projectId>.api.sanity.io/v1/data/stats/<datasetName> - look for fields.count.value.

If you're concerned about hitting the limit, the docs recommend focusing on semantic content structure rather than presentation, avoiding excessive nesting, and being mindful of localization approaches that can multiply your attribute count.

Show original thread
3 replies
Those would be separate attributes, I believe. I’m pretty bad at counting attributes but it’s possible it would be 4 paths total:
page
page.body
post
post.body
Thanks for the clarification 🙂
You’re welcome!

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.

Was this answer helpful?