
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! Building a historical version navigator is definitely doable with Sanity's History API. Here's what you need to know based on my experience and the docs:
You're correct that the History API isn't directly exposed through @sanity/client. Instead, you'll need to make direct HTTP requests to the history endpoints. The main endpoint you'll want to use is:
https://${projectId}.apicdn.sanity.io/v1/data/history/${dataset}/documents/${docId}?time=${time}This lets you fetch a document as it existed at a specific point in time, which is perfect for your dropdown navigation use case.
Here's a practical approach for building your version dropdown:
const historyUrl = `https://${projectId}.apicdn.sanity.io/v1/data/history/${dataset}/transactions/${docId}`;
const response = await fetch(historyUrl, {
headers: {
'Authorization': `Bearer ${token}`
}
});Parse the transactions to build your dropdown menu - each transaction gives you a timestamp and change information
Fetch specific versions when users select from the dropdown using the time parameter shown above
History retention limits - Make sure you're aware of what your plan offers:
Input sanitization - Since you're building user-facing features, be sure to properly validate and sanitize document IDs and timestamps to prevent security issues. The History API documentation specifically calls this out.
Using client.request() - While the History API isn't built into the standard client methods, you can use the lower-level client.request() method to make authenticated requests to the history endpoints without manually handling tokens:
const history = await client.request({
url: `/data/history/${dataset}/documents/${docId}?time=${timestamp}`,
withCredentials: true
});This approach keeps your authentication handled by the client while still accessing the history endpoints.
If you need simpler access to recent changes, the document history feature in the Studio UI shows revisions, and you can programmatically restore documents using client.createOrUpdate() with data from historical versions.
Hope this helps! Let me know how it goes with your implementation.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store