canonical: https://jentic.com/apis/sanity.io/sanity

# Sanity HTTP API

REST API for the Sanity headless CMS platform. Query, mutate, and manage documents and datasets via GROQ queries and mutations. The API exposes 4 endpoints secured with apiKey, bearer authentication.

## For AI agents

Programmatically execute a groq query via post (for queries exceeding 11kb url limit), execute a groq query via get. Covers 4 operations with apiKey, bearer authentication.

## Scope

Does not handle payments, communications, or crm - use for developer tools only.

## Capabilities

- Execute a GROQ query via POST (for queries exceeding 11KB URL limit)
- Apply mutations to documents in a dataset
- Get documents by ID, bypassing caching
- Query and filter Sanity HTTP API records by parameters
- Monitor Sanity HTTP API operational status and events

## Use cases

### Developer Tools Operations

Use the Sanity HTTP API to perform developer tools operations programmatically. The API provides 4 endpoints covering core functionality including execute a groq query via post (for queries exceeding 11kb url limit), execute a groq query via get, apply mutations to documents in a dataset.

Example prompt: Call POST /data/query/{dataset} to execute a groq query via post (for queries exceeding 11kb url limit)

### Automated Data Management

Automate data operations by combining multiple Sanity HTTP API endpoints. Agents can execute a groq query via get and then apply mutations to documents in a dataset in a single workflow.

Example prompt: Call GET /data/query/{dataset} to execute a groq query via get, then verify the result

### AI Agent Integration via Jentic

AI agents discover and call Sanity HTTP API endpoints through Jentic without managing credentials directly. An agent searches for the required operation by intent, receives the matching endpoint schema, and executes the call with Jentic-managed authentication. This eliminates the need to read API documentation or handle apiKey, bearer tokens manually.

Example prompt: Search Jentic for 'execute a groq query via post (for queries exceeding 11kb url limit)', load the operation schema, and execute with Jentic-managed credentials

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /data/query/{dataset} | Execute a GROQ query via POST (for queries exceeding 11KB URL limit) |
| GET | /data/query/{dataset} | Execute a GROQ query via GET |
| POST | /data/mutate/{dataset} | Apply mutations to documents in a dataset |
| GET | /data/doc/{dataset}/{documentIds} | Get documents by ID, bypassing caching |

## Key resources

- **Data** — Operations for data

## Why Jentic

- **Setup:** Wiring the Sanity HTTP API by hand means handling its token auth, substituting your project id into the host, choosing between the API and apicdn endpoints, and naming the dataset in every query or mutation. Through Jentic you install once, import the Sanity HTTP API from the API Directory, store the token once, and your agent calls it.
- **Permission scoping:** Sanity puts the dataset in the URL path (/data/query/{dataset} and /data/mutate/{dataset}), so a rule can pin your agent to one dataset. You choose the operations it may call, so a write operation like a mutation is not included unless you add it alongside the read query.
- **Credential handling:** Your Sanity token is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'run a GROQ query' or 'fetch a document by id', and Jentic returns the matching Sanity HTTP API operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Github** — Alternative developer tools API
- **Gitlab** — Alternative developer tools API

## FAQ

### What authentication does the Sanity HTTP API use?

The Sanity HTTP API uses apiKey, bearer authentication. Through Jentic, these credentials are stored encrypted in your Jentic One instance and injected at execution time, so raw secrets never enter the agent context.

### Can I execute a groq query via post (for queries exceeding 11kb url limit) with the Sanity HTTP API?

Yes. Use the POST /data/query/{dataset} endpoint. The API returns structured JSON responses that agents can parse and act on directly.

### What are the rate limits for the Sanity HTTP API?

Rate limits are not specified in the OpenAPI spec. Check the vendor documentation for current limits. Through Jentic, rate limiting is handled automatically with retry logic built into the execution layer.

### How do I execute a groq query via post (for queries exceeding 11kb url limit) through Jentic?

Install the Jentic SDK with pip install jentic, authenticate through Jentic One, the self-hosted execution layer, then search for 'execute a groq query via post (for queries exceeding 11kb url limit)'. Jentic returns the matching Sanity HTTP API operation with its input schema. Load the schema and execute the call - credentials are injected automatically.

### How many endpoints does the Sanity HTTP API have?

The Sanity HTTP API exposes 4 endpoints covering data operations.

### Can I limit what my agent is allowed to do with the Sanity HTTP API?

Yes. Because you run Jentic One yourself, your own rules decide which Sanity operations and credentials the agent may use. Sanity puts the dataset in the URL path, so a rule can pin the agent to a single dataset across both /data/query/{dataset} reads and /data/mutate/{dataset} writes. You also choose exactly which operations it may call, so a mutation stays out of reach unless you add it alongside the read query.
