Doc API reference

Retrieve one or more documents by ID and bypass the caching layer.

The Doc API bypasses caching, so every request goes to the backend. To fetch content in most cases, use the Query API instead.

Authentication

Requests to a public dataset don't need a token, but they return only published documents. To read drafts, release versions, or any document in a private dataset, authenticate requests with a token that has read access to those documents. Documents the request can't read aren't returned. Instead, the response lists their IDs in omitted with the reason permission.

Base API server URL

Sanity API base URL

https://{projectId}.api.sanity.io/{apiVersion}

Variables

  • projectIdstringdefault: "projectId"

    Sanity project ID

  • apiVersionstringdefault: "v2025-02-19"

    API version

Endpoints

Get one or more documents

get/data/doc/{dataset}/{documentId}

Returns the latest version of one or more documents by ID, without the delay of the query index. It is less scalable than the Query API, so use it only when you need the most recent write.

The endpoint accepts only the query parameters listed here. Any other parameter, including perspective, returns a 400 error.

Path parameters

  • datasetstringrequired
  • documentIdarrayrequired

    Comma-separated list of document IDs. IDs aren't validated beyond UTF-8 encoding, so an ID that doesn't match any document is listed in omitted with the reason existence.

    Example
    ["my-doc","drafts.my-doc"]
    items
    • itemsstring

Query parameters

  • includeAllVersionsbooleandefault: false

    If true, also return the draft and every release version of each published document ID you request. This only applies to published IDs: a draft or version ID returns only that document. Drafts and release versions are returned even if the published document doesn't exist, in which case the published ID is also listed in omitted with the reason existence.

    The parameter can be passed without a value (?includeAllVersions), which is the same as true.

    Requires API version v2025-02-19 or later. Earlier API versions reject the parameter with a 400 error.

  • excludeContentbooleandefault: false

    If true, return documents as null and return only omitted. Use this to check whether documents exist without fetching their content. The parameter requires a value: ?excludeContent without one returns a 400 error.

  • tagstring

    A tag to identify the request in logs. Can be passed only once.

Responses

200

Returns a list of matching documents. Document shape matches a Sanity document and includes all non-null fields.

  • documentsarray|null

    The documents the request can read. null when excludeContent is true.

    Show child attributes
    items
  • omittedarray

    IDs that weren't returned, with the reason. existence means no document has that ID. permission means the request can't read the document.

    Show child attributes
    items
sanity.ioAll Systems Operational© Sanity 2026
Change site theme