
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! Let me break down how drafts work and address your specific concerns about converting published documents to drafts.
In Sanity, drafts and published documents are separate entities in your dataset. A draft has an _id prefixed with drafts. (e.g., drafts.abc-123), while the published version has the plain ID (e.g., abc-123). When both exist, you have a published document with unpublished changes.
createIfNotExists to Create a DraftYes, using createIfNotExists with the drafts. prefix is the correct way to create a draft from an existing published document! It doesn't create an unrelated document—as long as you use the right ID format, Sanity recognizes the relationship.
Here's how to do it:
// To convert a published document to draft state
const publishedId = 'abc-123'; // your published document ID
client.createIfNotExists({
_id: `drafts.${publishedId}`,
...publishedDocumentData // copy the published document's data
})When you create a draft with _id: drafts.abc-123, Sanity understands this is the draft version of the published document abc-123. When someone publishes from the Studio, it will merge the draft with the published version.
You're correct—you cannot use patch to convert a published document into a draft state. The draft/published relationship is based on having two separate documents with the proper ID convention, not a status field you can patch.
createIfNotExists with the drafts. prefixOne thing to be aware of: if external systems update the published document while a draft exists, publishing the draft can overwrite those external changes. Make sure your workflow accounts for this—you might want to copy the latest published data when creating the draft to avoid losing recent updates.
So yes, createIfNotExists with the drafts. prefix is exactly the right approach for what you're trying to do!
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