Live content and API request usage
How Live Content API connections, SanityLive, and live preview count toward your API and API CDN request quotas, compared with fetching content without live updates.
Live content doesn't make a query cost more. A Live Content API connection doesn't send queries, and each query your app sends counts as one request whether or not you use live updates. What live content changes is when your app sends queries again: after content changes.
What counts toward each quota
- Live Content API connections: Count toward Live Content API usage, not toward API or API CDN requests. A connection listens for sync tags and doesn't request data.
- Queries for published content: Count toward API CDN requests when the client uses the API CDN, and toward API requests when it doesn't. In
next-sanity,sanityFetchuses the API CDN when it resolves to thepublishedperspective. - Queries for drafts and content releases: Count toward API requests. The API CDN only serves the published perspective, so draft and release queries always go to the API.
- Refetches after a content change: These are ordinary queries, and they count the same way as the first fetch of the same query.
Failed requests, and requests from Sanity Studio and other Sanity applications, don't count toward either request quota. See Plans and payments for how each quota is metered.
Billable requests per sanityFetch call
In next-sanity, the sanityFetch function that defineLive returns sends two requests for each query: one that looks up the query's sync tags, then one that fetches the result. The sync tag lookup's request tag ends in fetch-sync-tags, and requests with that tag suffix don't count toward your quotas. A query fetched with sanityFetch costs one billable request, the same as fetching it with client.fetch.
When you count requests in a request log export to compare with your usage, leave out requests whose tag ends in fetch-sync-tags.
Request usage of live preview
When an editor previews your app in Presentation Tool, the app runs in draft mode and queries drafts. Draft queries skip the API CDN, so preview requests count toward API requests. That's true of any preview that shows drafts, with or without live updates.
Live updates add requests while editors work. In a Next.js App Router app in draft mode, <SanityLive> refreshes the whole route each time it receives a content change event. It doesn't compare the event's sync tags with the page's queries first, and Next.js doesn't cache fetches in draft mode, so every sanityFetch call on the route sends a new billable request. A preview where an editor is actively editing sends more requests than a preview that fetches only when the page loads, and a page with many separate queries multiplies the cost of each refresh.
Preview requests grow with the number of editors previewing and how much they edit, not with your site's visitors. To keep each refresh cheap, keep the page's queries few and narrow. See Keep Presentation fast on large pages.
Request usage of live updates for published content
For published content, a content change revalidates only the cached responses whose sync tags match it, and your app fetches them again the next time they're requested. A response tagged with a document ID is revalidated when that document changes. A response tagged with a document type is revalidated on every change to a document of that type, and a response with the dataset-wide tag is revalidated on every change in the dataset.
Whether live content sends more or fewer requests than your current setup depends on how often your content changes and how specific your queries' sync tags are. Imports, migrations, and scripts that write to published documents emit change events like any other edit, so a bulk write can revalidate many cached responses at once, followed by a burst of refetches as they're requested. See Sync tags for how Content Lake assigns tags, how to keep them narrow, and how to soften refetch spikes from bulk writes.
On next-sanity v12 with Next.js 16, link prefetching can multiply the requests that follow each live event. See Next.js 16 and SanityLive: avoiding request overages.
Next steps
- To find which queries, callers, and request tags account for your API requests, see Diagnose an API request spike.
- To keep live updates from revalidating more cached responses than they need to, see Sync tags.
- To learn how live connections deliver content change events, see Live Content API.
Was this page helpful?
Feedback submitted, thanks for helping us improve the docs. Have you tried these alternatives?