How long to wait after exceeding Sanity API limit?

2 replies
Last updated: Sep 21, 2022
I exceeded my API limit, how long do I have to wait?
AI Update

When you exceed Sanity's API rate limit, the wait time depends on which specific limit you hit. According to the technical limits documentation, Sanity enforces rate limits in two ways:

Per-IP Rate Limits (enforced per second):

  • Maximum mutation rate: 25 requests/second
  • Maximum upload rate: 25 requests/second
  • Maximum global API call rate: 500 requests/second

Concurrent Rate Limits (per dataset):

  • Maximum concurrent queries: 500
  • Maximum concurrent mutations: 100

When you hit a rate limit, you'll receive an HTTP 429 response with helpful headers:

  • retry-after: Tells you how many seconds to wait before retrying
  • ratelimit-reset: Time in seconds until the limit resets
  • x-ratelimit-limit-*: Shows your rate limit threshold
  • x-ratelimit-remaining-*: Shows how many requests you have left

How long to wait:

Since these are rolling window limits (measured per second), you typically only need to wait 1-2 seconds for the per-IP limits to reset. The key is to check the retry-after header in the 429 response - it will tell you the exact wait time.

Best practices to avoid hitting limits:

  1. Implement exponential backoff: When you get a 429, check the retry-after header and wait that duration before retrying
  2. Throttle batch operations: For mutations, stay well under 25 req/s by adding delays between requests (50-100ms works well)
  3. Use the API CDN: Cached responses through the API CDN have unlimited rate limits
  4. Process in smaller batches: Break large operations into chunks of 10-20 requests at a time

For most use cases, spacing out your requests by 40-50ms will keep you comfortably under the 25 req/s mutation limit without triggering rate limiting at all.

Show original thread
2 replies
Your API limit resets on the first of every month. You can also add a credit card to pay for overages if you'd like to continue using the API.
I've added a credit card already

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?