
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storePublishing content via the HTTP API in Sanity is actually quite straightforward once you understand how the draft/published document system works!
In Sanity, draft and published documents are stored as two separate documents in your Content Lake. The key difference is their _id:
drafts. (e.g., drafts.post-123)post-123)To publish a document using the Mutation API, you essentially need to:
drafts. prefix)Here's a practical example using createOrReplace:
POST https://YOUR-PROJECT-ID.api.sanity.io/v2025-02-19/data/mutate/YOUR-DATASET
{
"mutations": [
{
"createOrReplace": {
"_id": "post-123",
"_type": "post",
"title": "My Published Post",
"content": "This is now live"
}
},
{
"delete": {
"id": "drafts.post-123"
}
}
]
}If you want to create content as a draft initially (not published), simply use the drafts. prefix:
{
"mutations": [
{
"create": {
"_id": "drafts.post-123",
"_type": "post",
"title": "Draft Post"
}
}
]
}Then when you're ready to publish, use the createOrReplace mutation shown above to copy the content to the published ID and delete the draft.
drafts. prefix), which is what you want for productionThe Mutation API supports several mutation types: create, createIfNotExists, createOrReplace, patch, and delete - all documented in the Mutation API docs.
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