Sanity · Arazzo Workflow

Sanity Replace Document Asset

Version 1.0.0

Upload a new image, find the target document, then point it at the new asset.

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

Provider

sanity

Workflows

replace-document-asset
Swap a document's image to a newly uploaded asset reference.
Uploads a replacement image, confirms the target document exists, and patches its image field to reference the new asset.
3 steps inputs: apiToken, dataset, documentId, filename, imageBinary, projectId outputs: assetId, assetUrl, documentId
1
uploadReplacement
Upload the replacement image and capture its asset document id.
2
findDocument
Read the target document by id to confirm it exists before patching.
3
patchAsset
Patch the document's image field so its asset reference points at the newly uploaded asset.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: Sanity Replace Document Asset
  summary: Upload a new image, find the target document, then point it at the new asset.
  description: >-
    An asset-swap flow for the Content Lake. The workflow uploads a replacement
    image, reads the target document to confirm it exists, and then patches that
    document's image field so its asset reference points at the newly uploaded
    asset. 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: assetsApi
  url: ../openapi/sanity-assets-api-openapi.yml
  type: openapi
- name: mutationsApi
  url: ../openapi/sanity-mutations-api-openapi.yml
  type: openapi
- name: queryApi
  url: ../openapi/sanity-query-api-openapi.yml
  type: openapi
workflows:
- workflowId: replace-document-asset
  summary: Swap a document's image to a newly uploaded asset reference.
  description: >-
    Uploads a replacement image, confirms the target document exists, and
    patches its image field to reference the new asset.
  inputs:
    type: object
    required:
    - projectId
    - apiToken
    - dataset
    - documentId
    - imageBinary
    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 document and receiving the asset.
      documentId:
        type: string
        description: The _id of the document whose image asset is being replaced.
      imageBinary:
        type: string
        description: Raw binary image content for the replacement asset.
      filename:
        type: string
        description: Optional original filename to record on the asset.
  steps:
  - stepId: uploadReplacement
    description: Upload the replacement image and capture its asset document id.
    operationId: uploadImageAsset
    parameters:
    - name: Authorization
      in: header
      value: "Bearer $inputs.apiToken"
    - name: dataset
      in: path
      value: $inputs.dataset
    - name: filename
      in: query
      value: $inputs.filename
    requestBody:
      contentType: image/*
      payload: $inputs.imageBinary
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      assetId: $response.body#/document/_id
      assetUrl: $response.body#/document/url
  - stepId: findDocument
    description: Read the target document by id to confirm it exists before patching.
    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]{_id}"
        params:
          id: $inputs.documentId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      foundId: $response.body#/result/_id
  - stepId: patchAsset
    description: >-
      Patch the document's image field so its asset reference points at the
      newly uploaded asset.
    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:
        - patch:
            id: $inputs.documentId
            set:
              image:
                _type: image
                asset:
                  _type: reference
                  _ref: $steps.uploadReplacement.outputs.assetId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      transactionId: $response.body#/transactionId
      documentId: $response.body#/results/0/id
  outputs:
    assetId: $steps.uploadReplacement.outputs.assetId
    assetUrl: $steps.uploadReplacement.outputs.assetUrl
    documentId: $steps.patchAsset.outputs.documentId

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-replace-document-asset-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.