
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou're hitting Sanity's 4MB request body limit for mutation API requests, which is a hard limit documented in their technical limits. When migrating data with large portable text fields, here are your workaround options:
Break your large documents into smaller pieces before importing. For portable text specifically, you can:
Example using the Sanity client with batching:
const {default: PQueue} = require('p-queue')
const queue = new PQueue({
concurrency: 1,
interval: 1000 / 25 // Stay under 25 req/s rate limit
})
// Split large documents and queue them
largeDocs.forEach(doc => {
queue.add(() => client.create(doc))
})The CLI import tool (sanity dataset import) is designed for bulk operations and may handle large documents more efficiently than direct API mutations:
sanity dataset import my-data.ndjson production --replaceHowever, individual documents still can't exceed the 32MB document size limit.
While not explicitly documented, you could try using gzip compression with the Content-Encoding: gzip header on your mutation requests. This might help if your portable text is highly compressible, though the 4MB limit likely applies to the uncompressed payload.
Consider if your portable text fields are too large and should be split into:
The transactions documentation recommends keeping transaction payloads reasonable and using throttling libraries like p-throttle for bulk operations.
If you're doing a one-time migration, the NDJSON import approach is your best bet. For ongoing operations, you'll need to architect your content to stay within these limits.
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