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

# Sanity History HTTP Endpoint

The Sanity History API returns past revisions of documents in a Sanity dataset and the transactions that changed them. A document can be fetched as it was at a given timestamp, at a specific revision ID, or at its last revision, which for a deleted document is its final state before deletion. Transaction logs come back as NDJSON for the whole dataset or for a comma-separated list of document IDs, filtered by time range, transaction range, and author IDs, with effects expressed in the Mendoza diff format. Access follows the document's current permissions, so anyone who can read a document today can read all of its earlier revisions.

## For AI agents

Fetch a Sanity document as it was at a past time or revision, and list the transactions that changed a dataset or specific documents, filtered by time, author, and transaction range.

## Scope

Does not write, restore, or publish documents, and does not run GROQ queries. Use for reading past document revisions and transaction logs in a Sanity dataset only.

## Capabilities

- Fetch a document as it was at a past timestamp with the time parameter
- Retrieve a specific document revision by its revision ID, or the last state before deletion with lastRevision
- List NDJSON transactions for a whole dataset between fromTime and toTime, with a limit
- Get the transactions for a comma-separated list of document IDs to see who changed them and when
- Filter transactions by author IDs and return them in reverse order to see the newest first
- Read change effects in the Mendoza format to reconstruct what each transaction did

## Use cases

### AI agent content audit

An agent asked 'who changed this page and what was it before?' needs Sanity's revision trail. Through Jentic it searches for 'get a past version of a Sanity document', loads the History revision operation, and requests the document at a timestamp while the Sanity token is injected at call time. It can then pull the document's transactions to name the authors and times of each change.

Example prompt: Call GET `/data/history/production/documents/homepage` with time '2026-11-10T09:00:00Z', then GET `/data/history/production/transactions/homepage` with excludeContent true and reverse true to list who changed it since

### Restoring deleted or overwritten content

When an editor deletes or overwrites a document by mistake, the earlier content is still in its history. Requesting the document with lastRevision returns its final state before deletion, and a known revision ID returns exactly that version, ready to be written back through the Sanity mutation endpoints.

Example prompt: Call GET `/data/history/production/documents/post-123` with lastRevision true and return the document body so it can be recreated

### Change feed for reporting

Editorial teams want a record of what changed in a period. The dataset-wide transactions endpoint returns NDJSON entries between fromTime and toTime or between two transaction IDs, filtered by authors, with excludeContent set to true as the spec requires. A limit keeps responses small, which the spec strongly recommends.

Example prompt: Call GET `/data/history/production/transactions` with excludeContent true, fromTime '2026-11-01T00:00:00Z', toTime '2026-11-08T00:00:00Z', authors 'pDYrmFKn7', and limit 200

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/data/history/{dataset}/documents/{documentId}` | Get a document revision |
| GET | `/data/history/{dataset}/transactions` | Get transactions for all documents |
| GET | `/data/history/{dataset}/transactions/{documentIds}` | Get transactions for listed documents |

## Key resources

- **Document revisions** — A document as it was at a timestamp, a revision ID, or its last revision
- **Transactions** — NDJSON change records with authors, timestamps, and Mendoza effects

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 70 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 100 / 100
  - Developer Experience & Jentic Compatibility: 63 / 100
  - AI-Readiness & Agent Experience: 52 / 100
  - Agent Usability: 94 / 100
  - Security: 75 / 100
  - AI Discoverability: 71 / 100
- **View full report:** https://jentic.com/apis/sanity.io/sanity-history/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring the Sanity History API by hand means templating the projectId and apiVersion into the host, sending a bearer token with read access, remembering that excludeContent must be true on transaction calls, and parsing NDJSON responses. Through Jentic you install once, import it from the API Directory, store the token once, and your agent calls it.
- **Permission scoping:** Sanity puts the dataset and document IDs in the URL path (`/data/history/{dataset}/documents/{documentId}`), so a rule can pin your agent to one dataset or even one document's history. Every operation is a read, and the token's own permissions decide which documents come back.
- **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 'get a past version of a Sanity document' or 'list recent Sanity edits', and Jentic returns the matching History operation with its path and query parameters.

## Related APIs

- **Sanity Doc API** — Fetch the current version of documents by ID
- **Sanity Actions API** — Write a recovered revision back and publish it
- **Sanity Activity Log API** — Project-level audit events beyond document edits
- **Contentful** — Headless CMS with entry versions and snapshots

## FAQ

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

Per its OpenAPI spec, the Sanity History API uses a bearer token (a JWT-format Sanity token) in the Authorization header. The spec notes you need read access to a document's current version to read its transactions, and authentication is required for documents in private datasets. Through Jentic the token is stored by your own instance and attached at call time.

### Why does the Sanity History transactions request return 403?

The spec requires excludeContent to be true on both transactions endpoints. Transaction responses never include document contents, and requests without excludeContent=true, or with it set to false, are refused. Use the document revision endpoint when you need the content itself.

### Can I see revisions a user could not access at the time?

The History API applies current access control to every revision. If a token can read the document today, it can read all previous revisions of that document, whatever the permissions were when they were written.

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

The OpenAPI spec does not specify rate limits. Check the Sanity documentation at https://www.sanity.io/docs for current API limits for your plan, and pass limit on transaction requests as the spec recommends.

### Is there a Sanity MCP server?

You don't need an MCP server to give your agent the Sanity History API. Jentic connects it directly from the API Directory: import it, store your Sanity token once, and your agent calls the revision and transaction operations with their input schemas when it needs them.

### How do I get a past version of a Sanity document through Jentic?

Search Jentic for 'get a past version of a Sanity document', load the revision operation, and execute GET `/data/history/{dataset}/documents/{documentId}` with either time, revision, or lastRevision, since the three are mutually exclusive. To run it on your own infrastructure, install Jentic One from its GitHub repo.

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

Yes. Write a rule that allows only the revision operation under `/data/history/staging/documents`/, and the agent can look up earlier versions of staging documents but cannot pull the transaction log or read production history. Every call it makes is logged.
