Sanity Mutations API

Create, update, and delete document operations

OpenAPI Specification

sanity-mutations-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Sanity HTTP Assets Mutations API
  description: The Sanity HTTP API provides access to the Sanity Content Lake platform, enabling querying, mutating, and managing structured content. The API supports GROQ queries, real-time event streaming, asset management, project management, webhooks, scheduling, and AI-powered content agents. Authentication uses Bearer tokens generated from Sanity project settings.
  version: v2024-01-01
  contact:
    name: Sanity Support
    url: https://www.sanity.io/docs
  license:
    name: Commercial
    url: https://www.sanity.io/legal/terms
servers:
- url: https://{projectId}.api.sanity.io/v{apiVersion}
  description: Sanity project-scoped API endpoint
  variables:
    projectId:
      description: Your Sanity project ID
      default: your-project-id
    apiVersion:
      description: API version date (YYYY-MM-DD)
      default: '2024-01-01'
- url: https://api.sanity.io/v{apiVersion}
  description: Sanity management API endpoint
  variables:
    apiVersion:
      description: API version date
      default: '2024-01-01'
security:
- BearerAuth: []
tags:
- name: Mutations
  description: Create, update, and delete document operations
paths:
  /data/mutate/{dataset}:
    post:
      operationId: mutateDocuments
      summary: Mutate Documents
      description: Apply a batch of mutations (create, createOrReplace, createIfNotExists, patch, delete) to documents in the dataset.
      tags:
      - Mutations
      parameters:
      - name: dataset
        in: path
        required: true
        schema:
          type: string
        description: Dataset name
      - name: returnIds
        in: query
        schema:
          type: boolean
        description: Return document IDs of created/modified documents
      - name: returnDocuments
        in: query
        schema:
          type: boolean
        description: Return full documents after mutations
      - name: visibility
        in: query
        schema:
          type: string
          enum:
          - sync
          - async
          - deferred
        description: Mutation visibility mode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MutationsRequest'
      responses:
        '200':
          description: Mutation results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MutationResponse'
components:
  schemas:
    MutationResponse:
      type: object
      properties:
        transactionId:
          type: string
        results:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              operation:
                type: string
    MutationsRequest:
      type: object
      required:
      - mutations
      properties:
        mutations:
          type: array
          items:
            type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Sanity project API token