Content Lake (Datastore)

Purge CDN caches

Remove cached query results, images, and files from Sanity's CDN with the cache purge API.

Use the purge API for emergency removal of cached query results or individual assets from Sanity's CDN.

Purges run in the background, typically taking seconds. They complete across all Sanity-controlled CDN cache layers within two hours of acceptance.

Before you begin

  • Self-service cache purging must be enabled for your project. Contact your Sanity account team about availability.
  • Use a user or robot token with permission to update project datasets. The Administrator and Developer roles include this permission.

Keep your token private and send requests from a trusted environment. See the API reference for endpoints, parameters, and responses.

The examples use SANITY_API_TOKEN. Replace the project ID, dataset name, and asset ID with your own values. Both requests have an empty body.

Choose a purge operation

Purge one image or file

An asset purge clears every cached representation of one dataset asset, including the original, resized images, transformations, and negotiated formats. Other assets and cached query results remain unchanged.

Use the asset document's _id, available through an asset reference's _ref. See Upload, query, and delete assets.

curl --request POST \
  --header "Authorization: Bearer $SANITY_API_TOKEN" \
  'https://api.sanity.io/v1/projects/myProjectId/datasets/production/assets/image-0123456789abcdef0123456789abcdef01234567-2000x1500-jpg/purges'

For a file, use its file document ID, such as file-0123456789abcdef0123456789abcdef01234567-pdf.

Purge a dataset's query results

A dataset purge clears cached GROQ and GraphQL query results for one project and dataset from the API CDN. Cached images and files remain unchanged.

curl --request POST \
  --header "Authorization: Bearer $SANITY_API_TOKEN" \
  'https://api.sanity.io/v1/projects/myProjectId/datasets/production/purges'

Queries fetch fresh results after a purge, which can temporarily increase response times and backend load.

The first purge is ready to run upon acceptance. Requests for the same dataset during the next ten minutes join one follow-up purge. They share its purgeId, and each gets its own acceptedAt. Additional requests leave the deadline unchanged.

Acceptance and completion

Both operations return 202 Accepted once the request is durably recorded:

{
  "purgeId": "3IVr59ieR2PO95KgrJzbF50HTtl",
  "acceptedAt": "2026-09-17T12:00:00Z"
}

Save these values. If you contact support about a purge, include the purge ID. Treat purgeId as an opaque string.

The two-hour completion commitment starts at acceptedAt and includes removing copies retained for stale-response or error fallback.

Activity log

Every accepted request gets a project Activity Feed entry confirming acceptance, including requests joining a pending purge. Each entry records the caller, target dataset or asset, and acceptance time. The Activity Log API exposes the purge ID as correlationId.

Viewing these events requires Activity Feed access. Retention follows your project's plan.

Limits and retries

Separate limits apply across all callers and datasets in a project:

  • Dataset query purges: 4 requests per hour.
  • Single-asset purges: 20 requests per minute.

Requests joining a pending dataset purge still count toward the limit. Rejected requests can also consume quota. For a 429 response, wait for the number of seconds in Retry-After before retrying.

Repeated asset requests start new purges.

Dataset requests can wait up to 30 seconds for acceptance confirmation. A purge may still execute after a timeout or 503. Retry with backoff; another purge may be created.

Limitations

  • Full dataset or project asset purges are unsupported.
  • URLs, paths, wildcards, transformation parameters, and batches of asset IDs are unsupported.
  • Media Library assets are currently unsupported.
  • Purges are available exclusively through the API.
  • Purge status and completion lookup by ID are unavailable.

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme