AutomationTasks

Sanity Fetch Schema

Fetch a Sanity document schema.

Task type: Sanity Fetch Schema

Use Sanity Fetch Schema to retrieve a document schema before generating or publishing Sanity content.

Run behavior

  • Side effects: This task is read-only or computation-only by default. It returns data for later steps rather than directly writing records or sending messages.
  • Credit usage: This task is not classified as credit-billed by the workflow task registry.

When to use this task

  • Generate structured content that must match a Sanity document type.
  • Give an AI Prompt task the schema it should conform to.
  • Validate your workflow inputs before a publish step.

Setup tips

  • Use the same project id and dataset as the publish step.
  • Fetch the schema before generating the document.
  • Pass the schema into AI Prompt with the json filter.

Examples

Fetch case study schema

Fetch the caseStudy schema and pass it to AI Prompt before generating a draft document.

Outputs

  • Sanity schema data for the selected document type.

Common pitfalls

  • Fetching a schema from a different dataset than the publish target.
  • Skipping schema context before asking AI to generate content.
  • Assuming schema fetch validates the final publish payload.

Reference details

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

Required fields

  • projectId
  • documentType

Variable-aware fields

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

  • documentType

Liquid template fields

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

  • documentType

Builder guidance

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

Use before Sanity publish tasks that need schema context.

Default configuration

New instances of this task start with the following configuration:

{
  "name": "Sanity Fetch Schema",
  "outputKey": "sanity_fetch_schema",
  "taskType": "Sanity Fetch Schema",
  "description": "",
  "projectId": "",
  "dataset": "production",
  "documentType": ""
}

On this page