Clarification on using the mutate API to draft posts in Sanity.io
Yes, the Mutate API absolutely allows you to create drafts without publishing! You do this by prefixing the document _id with drafts.
Creating Drafts via the Mutate API
When you want to save a document as a draft (not published), simply add the drafts. prefix to the _id:
{
"create": {
"_id": "drafts.post-123",
"_type": "post",
"title": "Example Post"
}
}This creates a draft document that exists separately from any published version. When you later publish it from Sanity Studio, the draft merges with the published document.
About those 500 errors...
500 errors from the Mutate API can have several causes. Here are the most common culprits:
1. Document size limits
- Maximum document size is 32 MB
- Maximum mutation request body size is 4 MB
2. Rate limits
- Maximum mutation rate: 25 requests/second per IP
- Maximum concurrent mutations: 100 per dataset
- If you exceed these, you'll get 429 errors, but sustained rate limit violations could cause other issues
3. Attribute limits
- Free/Growth plans: max 1000 attributes per document
- Enterprise: max 8000 attributes per document
- Maximum nesting depth: 20 levels
4. Authentication issues
- Make sure your token has write permissions
- Verify your
Authorizationheader is properly formatted
5. Validation or malformed data
- Invalid field types
- Missing required fields (like
_type) - Circular references
Debugging tips
To troubleshoot your 500 errors:
- Check the response body - it should contain error details
- Verify your document structure - make sure it matches your schema
- Test with a minimal document - try creating the simplest possible draft first
- Check your token permissions - ensure it has write access to your dataset
- Review the HTTP Mutations documentation for the full API reference
The draft functionality itself is rock-solid and widely used, so the 500 errors are likely related to one of the limits or data issues above rather than the draft mechanism itself.
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.