AutomationTasks

Sanity Publish Document

Publish a document to Sanity CMS.

Task type: Sanity Publish Document

Use Sanity Publish Document to create or update a document in Sanity CMS.

Run behavior

  • Side effects: This task can change data or call an external system. Test with safe records and be careful when rerunning.
  • Credit usage: This task is not classified as credit-billed by the workflow task registry.

When to use this task

  • Publish generated case studies, customer stories, or enablement content.
  • Update the same Sanity document id on reruns.
  • Send structured workflow output into a CMS.

Setup tips

  • Use a stable document id when reruns should update the same document.
  • Generate and validate the document object before publishing.
  • Test against a non-production dataset when possible.

Examples

Publish generated case study

Publish {{ steps.2.object | json_compact }} as a caseStudy document with id case-study-{{ inputs.account_id }}.

Outputs

  • Sanity publish result metadata.

Common pitfalls

  • Publishing raw text instead of valid JSON.
  • Generating a new document id on every rerun unintentionally.
  • Testing against production before the payload is validated.

Reference details

These details are generated from the workflow task registry and match the fields available in the builder.

Required fields

  • projectId
  • documentId
  • documentType
  • document

Variable-aware fields

Fields that accept variable references ({{ inputs.x }}, {{ steps.N.y }}) from the workflow's variable graph:

  • documentId
  • documentType
  • document

Liquid template fields

Fields that are rendered through Liquid (variables plus filters and control flow):

  • documentId
  • documentType
  • document

Builder guidance

When the Workflow Builder Genie configures this task, it follows this guidance:

Confirm side effects and validate the document against fetched schema when possible.

Default configuration

New instances of this task start with the following configuration:

{
  "name": "Sanity Publish Document",
  "outputKey": "sanity_publish_document",
  "taskType": "Sanity Publish Document",
  "description": "",
  "projectId": "",
  "dataset": "production",
  "documentId": "",
  "documentType": "",
  "document": "{}",
  "apiVersion": "2021-06-07"
}

On this page