Index
Edit

URL Format

Take this generic document query-url:

https://zp7mbokg.api.sanity.io/v1/data/query/production?query=*[0]

Each project has it's own private host-name, which is always <projectId>.api.sanity.io for normal requests and <projectId>.apicdn.sanity.io for the api CDN (cache) endpoint. The path always starts with the api-version (always v1 at the moment) then the path to whatever endpoint is targeted. So, to sum it up, these are the url prefixes:

  • API proper: https:<projectId>.api.sanity.io/v1/<path>
  • API CDN: https:<projectId>.apicdn.sanity.io/v1/<path>

In the rest of this document we will generally only refer to the <path>-part of the url.

Caveat: The API CDN only supports the /data/query-endpoint, it's only purpose being caching query-results across the globe for the benefit of your end-users.

How do I find my project id?

In a configured studio, you find the project id in the sanity.json-file at the root of your project. Otherwise you can always find it by locating your project on https://manage.sanity.io.

URL encoding

For clarity we have opted to write the url's with their component in clear text. In real life they will all have to be encoded (using encodeURIComponent or equivalent) so that this:

https://zp7mbokg.api.sanity.io/v1/data/query/production?query=*[_id == $id]&$id="myId"

Becomes this:

https://zp7mbokg.api.sanity.io/v1/data/query/production?query=*%5B_id%20%3D%3D%20%24id%5D&%24id=%22myId%22

Previous: HTTP APINext: Authentication