Skip to content
Maua.Culturewire

Sanity

Documents, GROQ queries and assets of your Sanity project

E-commerceCatalog2 tools · 0 triggers

Managed auth

Authentication

Methods your end users can connect with. Credentials are stored encrypted, and secret values are never shown again or returned by the API.

  • API key

    Your users enter

    • Project IDRequiredSubdomain
    • API tokenSecretRequired

    Where to find them

    1. At sanity.io/manage open the project → “API” → “Tokens” → “Add API token”.
    2. Give it a name and choose the permissions: “Viewer” to read (including drafts and private datasets) or “Editor” to write.
    3. Click “Save” and copy the token: it is shown only once.

Tools (2)

  • Sanity API requestSANITY_SEND_REQUEST

    Authenticated call to the Sanity API (https://{project}.api.sanity.io/v2025-02-19). Any endpoint of the API is allowed. Replace {dataset} with yours (list them with GET /datasets; it is usually production). Examples: GET /data/query/{dataset}?query=*[_type == "post"] | order(_updatedAt desc)[0...10]{_id, title} (with perspective=drafts it also sees drafts), GET /data/doc/{dataset}/{id}, POST /data/mutate/{dataset}?returnIds=true {"mutations": [{"create": {"_type": "post", "title": "…"}}]} (also createOrReplace, patch {"id": …, "set": {…}} and delete {"id": …}), POST /assets/images/{dataset} (body_base64 + content_type), GET /users/me, GET https://api.sanity.io/v2025-02-19/projects/{project} (project management).

    Required scopes

    No scopes required

    Input

    Sanity API request input
    NameTypeDescription
    methodstringHTTP methodOne of: GET, POST, PUT, PATCH, DELETEDefault: "GET"
    pathrequiredstringPath relative to the API base URL, or a full URL on the same API (e.g. a next-page link)
    queryobjectQuery string parameters
    bodyunknownJSON body
    formobjectBody as application/x-www-form-urlencoded instead of JSON
    body_base64stringBinary body, base64 (at most 960000 characters)
    content_typestringContent-Type of body_base64
    headersobjectExtra headers such as Accept. Authentication is added automatically.
  • GROQ querySANITY_RUN_QUERY

    Runs a GROQ query on a dataset and returns the result. By default it only sees published documents; with drafts=true it uses the “drafts” perspective (drafts on top of what is published).

    Required scopes

    No scopes required

    Input

    GROQ query input
    NameTypeDescription
    groqrequiredstringGROQ query, e.g. *[_type == "post"] | order(_updatedAt desc)[0...10]{_id, title, "slug": slug.current}
    parametersobjectValues of the $parameters, e.g. {"type": "post"}
    datasetstringDefault: "production"
    draftsbooleanDefault: false