
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! The "total documents" number in Sanity usage is calculated with some specific rules that might explain why your GROQ query results differ.
According to the Plans and Payments documentation, the Documents quota is defined as:
"total number of stored documents (including drafts) across all datasets at the end of the month"
Important exclusions:
sanity.imageAsset, configuration documents, etc.)Based on the community discussion, here's how to replicate the usage count:
count(*[_type in $types])Where $types is an array of the document types you've defined in your schema (excluding system documents and assets).
If you're getting too many documents, you're likely including:
_id starting with _)sanity.imageAsset, sanity.fileAsset)If you're getting too few, you might be:
_id starting with drafts.)Yes, documents count across ALL datasets in your project. The quota is per-project, not per-dataset. So if you have multiple datasets (like production, staging, development), all their documents add up to your total count.
To get an accurate count excluding system documents and assets:
count(*[!(_id in path("_.**")) && !(_type match "sanity.*")])This excludes:
_ path)sanity.imageAsset)Remember that this count includes drafts, which is consistent with how Sanity calculates your usage quota.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store