Sanity · Capability

Sanity HTTP API — Query

Sanity HTTP API — Query. 2 operations. Lead operation: Query Documents. Self-contained Naftiko capability covering one Sanity business surface.

Run with Naftiko SanityQuery

What You Can Do

GET
Querydocuments — Query Documents
/v1/data/query/{dataset}
POST
Querydocumentspost — Query Documents (POST)
/v1/data/query/{dataset}

MCP Tools

query-documents

Query Documents

read-only idempotent
query-documents-post

Query Documents (POST)

read-only

Capability Spec

sanity-query.yaml Raw ↑
naftiko: 1.0.0-alpha2
info:
  label: Sanity HTTP API — Query
  description: 'Sanity HTTP API — Query. 2 operations. Lead operation: Query Documents. Self-contained Naftiko capability
    covering one Sanity business surface.'
  tags:
  - Sanity
  - Query
  created: '2026-05-19'
  modified: '2026-05-19'
binds:
- namespace: env
  keys:
    SANITY_API_KEY: SANITY_API_KEY
capability:
  consumes:
  - type: http
    namespace: sanity-query
    baseUri: https://{projectId}.api.sanity.io/v{apiVersion}
    description: Sanity HTTP API — Query business capability. Self-contained, no shared references.
    resources:
    - name: data-query-dataset
      path: /data/query/{dataset}
      operations:
      - name: querydocuments
        method: GET
        description: Query Documents
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: dataset
          in: path
          type: string
          description: Dataset name (e.g., production)
          required: true
        - name: query
          in: query
          type: string
          description: GROQ query string
          required: true
        - name: perspective
          in: query
          type: string
          description: Content perspective to query
        - name: explain
          in: query
          type: boolean
          description: Include query execution plan in response
        - name: resultSourceMap
          in: query
          type: boolean
          description: Include content source map metadata
      - name: querydocumentspost
        method: POST
        description: Query Documents (POST)
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: dataset
          in: path
          type: string
          description: Dataset name
          required: true
        - name: body
          in: body
          type: object
          description: Request body (JSON).
          required: true
    authentication:
      type: bearer
      token: '{{env.SANITY_API_KEY}}'
  exposes:
  - type: rest
    namespace: sanity-query-rest
    port: 8080
    description: REST adapter for Sanity HTTP API — Query. One Spectral-compliant resource per consumed operation, prefixed
      with /v1.
    resources:
    - path: /v1/data/query/{dataset}
      name: data-query-dataset
      description: REST surface for data-query-dataset.
      operations:
      - method: GET
        name: querydocuments
        description: Query Documents
        call: sanity-query.querydocuments
        with:
          dataset: rest.dataset
          query: rest.query
          perspective: rest.perspective
          explain: rest.explain
          resultSourceMap: rest.resultSourceMap
        outputParameters:
        - type: object
          mapping: $.
      - method: POST
        name: querydocumentspost
        description: Query Documents (POST)
        call: sanity-query.querydocumentspost
        with:
          dataset: rest.dataset
          body: rest.body
        outputParameters:
        - type: object
          mapping: $.
  - type: mcp
    namespace: sanity-query-mcp
    port: 9090
    transport: http
    description: MCP adapter for Sanity HTTP API — Query. One tool per consumed operation, routed inline through this capability's
      consumes block.
    tools:
    - name: query-documents
      description: Query Documents
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: sanity-query.querydocuments
      with:
        dataset: tools.dataset
        query: tools.query
        perspective: tools.perspective
        explain: tools.explain
        resultSourceMap: tools.resultSourceMap
      outputParameters:
      - type: object
        mapping: $.
    - name: query-documents-post
      description: Query Documents (POST)
      hints:
        readOnly: true
        destructive: false
        idempotent: false
      call: sanity-query.querydocumentspost
      with:
        dataset: tools.dataset
        body: tools.body
      outputParameters:
      - type: object
        mapping: $.