Sanity provides two APIs:

  1. The live, uncached API is the default and will always give you the freshest data. The downside of using it is that requests will be slightly slower because they need to reach our backend on every request. Requests are also more costly, because they will trigger more computation on our servers.
  2. The CDN-distributed, cached API, which is an opt-in feature that will give you very fast responses to requests that have been cached. We encourage most users to use this API for their front-ends unless there is a good reason not to.

To use the CDN API, simply use instead of Most clients provide a useCdn option that makes this switch seamless.

There are a couple of scenarios where the CDN API cannot be used:

  • When a mutation is performed (creating/editing/deleting documents)
  • When listeners are used (subscribing to changes)
  • When requests are authenticated using an access token or cookie.

All official clients will automatically fall back to using the live API in these cases.

Currently, the API caches requests for 15 seconds. In the future, this will be configurable on a per-dataset level.

Previous: WebhooksNext: Command Line Interface