Publish Draft Document
A 3-step recipe with Sanity. We can help you get access.
Recipe · 3 steps
Publish Draft Document
with Sanity
Promote a draft document to published and confirm it landed.
- Read the draft document by its drafts-prefixed id to confirm a draft exists before promoting it.
- Create or replace the published document from the supplied body and delete the draft in a single mutation batch.
- Query the published id to confirm the document is now present in the published perspective.
What you'll need to have ready
- projectId: The Sanity project id that scopes the API endpoint.
- apiToken: Sanity project API token used as a Bearer credential.
- dataset: Dataset name holding the draft and published documents.
- publishedId: The published _id (the draft is drafts.<publishedId>).
- publishedDocument: The document body to publish, including _type. Its _id is set by the workflow from publishedId.
For your developer
Arazzo workflow sanity:publish-draft-document, 3 operations: queryDocumentsPost → mutateDocuments → queryDocumentsPost. Specs on APIs.io.