Joint session with Vercel: How to build intelligent storefronts (May 15th)

How to publish content via Sanity HTTP API?

7 repliesLast updated: Nov 29, 2025

I have custom project with HTTP-api, that i am
writing
to Sanity Content Lake. My question how do i "publish" the content via HTTP-api?
AI Update

Publishing 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:

How to "Publish" via HTTP API

To publish a document using the Mutation API, you essentially need to:

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"
      }
    }
  ]
}

Creating Drafts First

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.

Important Notes

The Mutation API supports several mutation types: create, createIfNotExists, createOrReplace, patch, and delete - all documented in the Mutation API docs.

Show original thread
7 replies

Was this answer helpful?

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.

Related contributions