> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# API Versioning

How to handle versioning in the Sanity API

Every Sanity API request is pinned to a version, written as a date. That version fixes the API's behavior, so your code keeps working the same way as the service evolves.

> [!TIP]
> The short version
> Use today's date when you start something new, written as a static string: `apiVersion: '2026-07-28'`.
> Then leave it alone. The next time you want to adopt a new feature, check whether it requires a newer version. If it does, update the date and confirm your existing queries and mutations still behave as expected.
> That covers what most projects need. The rest of this page explains what the version controls and what to watch for when you change it.

Every Sanity client takes the version as a configuration option, including the [official Sanity JavaScript client](https://www.sanity.io/docs/libraries). A client configured with 2026-07-28 uses the most recent API version released on or before July 28, 2026.

```javascript
const {createClient} = require('@sanity/client')

const client = createClient({
  projectId: 'YOUR_PROJECT_ID',
  dataset: 'YOUR_DATASET',
  apiVersion: '2026-07-28', // a static UTC date string
  token: '<sanity-auth-token>', // or leave blank for unauthenticated usage
  useCdn: true, // `false` if you want to ensure fresh data
})
```

## How API versions work

The URL of every API call includes an explicit version as the first path segment. The following call uses API version `v2026-06-24`:

`https://example.api.sanity.io/v2026-06-24/data/query/production?query=*`

From time to time, we may need to make breaking changes to our API functionality. We try very hard to avoid this, but it is *sometimes* necessary to fix bugs. A versioned API lets us make those improvements without breaking existing code.

To the best of our ability, we try to ensure that old versions of the API don't change, even as our services evolve. This may sometimes include "wrong" behavior that we choose to maintain if we deem that the fix might negatively impact users.

As long as we don't see the change as a breaking change, we may choose to introduce it also in older versions of the API.

## Version dates

Version dates are ISO 8601-formatted and use the UTC time zone. Any past or present date is valid, and today's date always resolves to the latest version, so there's no need to check the release history.

[Stripe inspired us](https://stripe.com/blog/api-versioning) to use dates instead of incremental version numbers (although our initial version is `v1`). We much prefer to release frequent small improvements rather than saving them up for a huge `v2` release. This allows us to get fixes into the hands of our users much sooner and makes it easier for our users to upgrade incrementally. With new versions released regularly, we believe it is more informative to use dates rather than rapidly increasing numbers.

## Client configuration

Clients should be configured with an explicit, static API version. See the [individual clients' documentation](https://www.sanity.io/docs/libraries) for details on how to do this. When starting new projects, clients should typically be given today's UTC date to get the most recent bugfixes and improvements. Older clients which do not support versioning will default to `v1`, our initial and outdated API version.

Write the date as a literal string. Computing it at runtime (for example from `new Date()`) means your API version changes every day, so a change to the API can alter your app's behavior without you deploying anything. A hardcoded date pins the behavior until you decide to move it.

The `apiVersion` property of the JavaScript client is optional. Omit it and the client issues a deprecation warning, then defaults to `v1` of the API. Passing the property with an undefined value throws an error instead.

When using the HTTP API, the version number is prefixed with the `v` character. The JavaScript client accepts the version with or without the prefix, and adds it when building the request URL.

## Upgrade to a newer version

> [!NOTE]
> Changelog
> Looking for the latest changes? Check them out in [the changelog](https://www.sanity.io/changelog).

To upgrade an application to a newer API version, first read our list of API changes to determine which (if any) modifications must be made to the application. Then, with a local instance of the application, set the newer API version for the client, make the necessary changes to the code, and then test the application either locally or in a staging environment. Once you are confident that the application correctly handles the new API version you can deploy it to production.

We recommend making multiple smaller upgrades rather than a single larger upgrade, to reduce the chance of anything breaking and make the job more manageable, but this is up to you to decide.

## Experimental API version

The special version `X` is used to test experimental changes. This version may change at any time in any way and is used at your own risk. Not only will it be backward-incompatible, but it may also cause data loss and other problems.

When using a version that isn't considered completely stable, the API will return a warning message in the `X-Sanity-Warning` header.

## Deprecation and removal

At times we will have to deprecate and then remove certain older versions of the API. We will always give appropriate notice when this is necessary.

In addition to notices on our website and to your registered email address, these versions will receive a warning through the `X-Sanity-Warning` header and also be tagged as deprecated via an `X-Sanity-Deprecated: true` HTTP header. Once an API version is removed, all calls to that version will return errors with code `410`.

## Backward-compatible changes

We consider the following changes to be backward-compatible and may therefore introduce them retroactively in old API versions. This list is not exhaustive.

- Adding new object attributes in JSON responses (outside of documents or query results)
- Changing the order of object attributes in JSON responses
- Adding new `_`-prefixed metadata attributes to stored or modified documents
- Adding new functionality to GROQ, such as operators, functions, and data types
- Adding new, optional parameters to API calls
- Adding new HTTP headers in responses
- Adding new endpoints to the API, or new methods to existing API endpoints

## GraphQL API versions

> [!WARNING]
> Gotcha
> **API versioning for v1 GraphQL queries. **
> `/v2023-03-01/graphql/**` endpoints use the same GROQ resolution as `/v1/graphql/**`.
> GraphQL API v2023-08-01 introduced [breaking changes](https://www.sanity.io/changelog/9ec89318-a340-4e23-91d9-3154da5b6244#5712319a77e4) to v1. You can opt in to new features or continue using the v1 API. See the [GraphQL documentation](https://www.sanity.io/docs/content-lake/graphql) for additional GraphQL endpoint and usage details.



## Related changelog entries

Entries are listed newest first; each link points to the full entry as markdown. Follow one when you need to know what changed, when, or why — for example, to summarize recent updates, explain behavior that differs from older documentation, or check whether a fix has shipped.

- [Content Lake v2021-03-25: New GROQ functions and versioning](https://www.sanity.io/docs/changelog/86e7b7ae-cbdf-4fca-9591-4a30bcedd396.md) — September 15, 2022
- [JavaScript Client v3.0.0: Major version upgrade to the JavaScript Client (@sanity/client)](https://www.sanity.io/docs/changelog/2965cfa8-5fe4-4c52-b307-135e13116dc7.md) — August 12, 2022