URL format
Every Sanity HTTP API request uses a URL made of your project's hostname, an API version, and an endpoint path: https://YOUR_PROJECT_ID.api.sanity.io/API_VERSION/PATH
Every Sanity HTTP API request uses a URL made of your project's hostname, an API version, and an endpoint path.
Take this generic document query URL:
https://<your-project-id>.api.sanity.io/v2026-06-09/data/query/production?query=*[0]Each project has its own hostname, which is always <your-project-id>.api.sanity.io for the uncached API and <your-project-id>.apicdn.sanity.io for the API CDN (cache) endpoint. Replace <your-project-id> with your project ID. The path (what comes after the hostname) always starts with the API version (API_VERSION): the letter v followed by a date in YYYY-MM-DD format. To use the latest version, set the date to today. After the version comes the path to the API endpoint (PATH). So, to sum it up, these are the URL prefixes:
- API:
https://<your-project-id>.api.sanity.io/API_VERSION/PATH - API CDN:
https://<your-project-id>.apicdn.sanity.io/API_VERSION/PATH
In the rest of this document we will generally only refer to the PATH part of the URL.
Note about the API CDN
The API CDN is meant for read requests. It caches GET requests and read-only POST requests to /data/query and /graphql, and rejects other POST requests because they can contain mutations.
Find your project ID
In a configured studio, you find the project ID in the sanity.config.ts (or sanity.config.js) file at the root of your project. Otherwise, you can always find it by locating your project on sanity.io/manage or running sanity debug in the terminal in your studio folder.
URL encoding
For clarity, the URLs in this article are written with their components unencoded. When you make a request, encode each component (using encodeURIComponent or equivalent) so that this:
https://<your-project-id>.api.sanity.io/v2026-06-09/data/query/production?query=*[_id == $id]&$id="myId"Becomes this:
https://<your-project-id>.api.sanity.io/v2026-06-09/data/query/production?query=*%5B_id%20%3D%3D%20%24id%5D&%24id=%22myId%22Gotcha
If you encode a URL that contains more than just a query string (that is, it includes params as well), encodeURIComponent() will encode the & between query and your params, which is probably not what you want. Instead, build the query string with URLSearchParams, which encodes each name and value separately. This is what @sanity/client does: it appends the GROQ query as query and each parameter as $name with a JSON-encoded value.
Was this page helpful?
Feedback submitted, thanks for helping us improve the docs. Have you tried these alternatives?