Sanity · Arazzo Workflow

Sanity Publish Draft Document

Version 1.0.0

Read a draft, promote it to a published document, then verify the result.

1 workflow 2 source APIs 1 provider
View Spec View on GitHub Headless CMSContent ManagementGROQReal-TimeStructured ContentDeveloper PlatformArazzoWorkflows

Provider

sanity

Workflows

publish-draft-document
Promote a draft document to published and confirm it landed.
Fetches the draft by its drafts-prefixed id, runs a mutation batch that creates or replaces the published document and deletes the draft, and verifies the published document with a follow-up query.
3 steps inputs: apiToken, dataset, projectId, publishedDocument, publishedId outputs: publishedDocument, transactionId
1
readDraft
Read the draft document by its drafts-prefixed id to confirm a draft exists before promoting it.
2
promoteDraft
Create or replace the published document from the supplied body and delete the draft in a single mutation batch.
3
verifyPublished
Query the published id to confirm the document is now present in the published perspective.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: Sanity Publish Draft Document
  summary: Read a draft, promote it to a published document, then verify the result.
  description: >-
    The draft-to-published promotion pattern in the Content Lake. The workflow
    reads a draft document by its drafts-prefixed id, then applies a mutation
    batch that creates or replaces the published document from that draft and
    deletes the draft, and finally queries the published id to confirm the
    promotion succeeded. Every step spells out its request inline so the flow
    can be read and executed without opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: mutationsApi
  url: ../openapi/sanity-mutations-api-openapi.yml
  type: openapi
- name: queryApi
  url: ../openapi/sanity-query-api-openapi.yml
  type: openapi
workflows:
- workflowId: publish-draft-document
  summary: Promote a draft document to published and confirm it landed.
  description: >-
    Fetches the draft by its drafts-prefixed id, runs a mutation batch that
    creates or replaces the published document and deletes the draft, and
    verifies the published document with a follow-up query.
  inputs:
    type: object
    required:
    - projectId
    - apiToken
    - dataset
    - publishedId
    - publishedDocument
    properties:
      projectId:
        type: string
        description: The Sanity project id that scopes the API endpoint.
      apiToken:
        type: string
        description: Sanity project API token used as a Bearer credential.
      dataset:
        type: string
        description: Dataset name holding the draft and published documents.
      publishedId:
        type: string
        description: The published _id (the draft is drafts.<publishedId>).
      publishedDocument:
        type: object
        description: >-
          The document body to publish, including _type. Its _id is set by the
          workflow from publishedId.
  steps:
  - stepId: readDraft
    description: >-
      Read the draft document by its drafts-prefixed id to confirm a draft
      exists before promoting it.
    operationId: queryDocumentsPost
    parameters:
    - name: Authorization
      in: header
      value: "Bearer $inputs.apiToken"
    - name: dataset
      in: path
      value: $inputs.dataset
    requestBody:
      contentType: application/json
      payload:
        query: "*[_id == $draftId][0]"
        params:
          draftId: "drafts.$inputs.publishedId"
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      draftDocument: $response.body#/result
  - stepId: promoteDraft
    description: >-
      Create or replace the published document from the supplied body and delete
      the draft in a single mutation batch.
    operationId: mutateDocuments
    parameters:
    - name: Authorization
      in: header
      value: "Bearer $inputs.apiToken"
    - name: dataset
      in: path
      value: $inputs.dataset
    - name: returnIds
      in: query
      value: true
    requestBody:
      contentType: application/json
      payload:
        mutations:
        - createOrReplace:
            _id: $inputs.publishedId
            _type: $inputs.publishedDocument._type
        - delete:
            id: "drafts.$inputs.publishedId"
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      transactionId: $response.body#/transactionId
  - stepId: verifyPublished
    description: >-
      Query the published id to confirm the document is now present in the
      published perspective.
    operationId: queryDocumentsPost
    parameters:
    - name: Authorization
      in: header
      value: "Bearer $inputs.apiToken"
    - name: dataset
      in: path
      value: $inputs.dataset
    requestBody:
      contentType: application/json
      payload:
        query: "*[_id == $id][0]"
        params:
          id: $inputs.publishedId
        perspective: published
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      publishedDocument: $response.body#/result
  outputs:
    transactionId: $steps.promoteDraft.outputs.transactionId
    publishedDocument: $steps.verifyPublished.outputs.publishedDocument

Work with this as data

Every workflow here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for arazzo workflows

4 MCP tools reach this
  • find_arazzoBrowse and filter every workflow in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This workflow
curl "https://apis.io/api/v1/arazzo/sanity-publish-draft-document-workflow"
All arazzo workflows
curl "https://apis.io/api/v1/arazzo?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.