Sanity import transaction size limits?

2 replies
Last updated: Nov 29, 2025
Hey there. I can't seem to find any size limits for sanity/import transactions? Are there any that I'd need to be aware of?
AI Update

Based on the documentation I've reviewed, here's what you need to know about transaction size limits for @sanity/import:

Transaction Size Limits for @sanity/import

While the @sanity/import package doesn't have explicitly documented transaction size limits in its own documentation, there are important API-level limits you need to be aware of:

Key Limits:

  1. Maximum mutation request body size: 4 MB - This is the critical limit for transactions. When importing data, the @sanity/import tool batches mutations into transactions, and each transaction request cannot exceed 4 MB.

  2. Maximum request body size: 100 MB - This applies to the overall HTTP request, but mutation requests specifically are limited to 4 MB.

  3. Maximum mutation rate: 25 requests/second - Rate limiting per IP address.

  4. Maximum concurrent mutations: 100 - Per dataset concurrency limit.

How @sanity/import Handles This:

According to the importing data documentation, when using client libraries (which @sanity/import uses under the hood):

  • Multiple mutations per transaction: It's recommended to batch multiple mutations within a single transaction, but you must ensure the request size stays within the 4 MB limit.
  • Automatic batching: The CLI import tool has built-in abstractions that automatically batch mutations into transactions to avoid rate limits.
  • Visibility mode: Using deferred visibility (instead of sync) makes imports faster, as it doesn't wait for documents to be searchable before returning.

Best Practices:

  1. Keep individual transaction payloads well under 4 MB
  2. Use the official CLI tool (sanity dataset import) which handles batching automatically
  3. If writing custom import scripts, implement proper batching and concurrency control (the docs recommend using libraries like p-queue with a concurrency of 1 request per 40ms, or 25 req/s)
  4. Monitor your request sizes, especially when importing documents with large content or many references

The 4 MB mutation request limit is the main constraint you'll encounter with @sanity/import transactions. The tool handles this automatically by batching your imports appropriately, but if you're building custom import logic, you'll need to manage this yourself.

Show original thread
2 replies

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?