Rate limits
Every authenticated request spends from a rate budget (opens in a new tab): a number of requests you may make in a window of time. The budgets leave plenty of room for a server doing its work, and stop a runaway loop before it does harm.
A budget belongs to an environment, not to a key. Every secret key of your live environment spends from the live budget, and every key of your sandbox from the sandbox budget. That has two consequences:
- A second key adds no capacity, and neither does a rolled key still in its grace period.
- Live and sandbox budgets are separate, so load in your sandbox never slows live.
- Live
- 100
- Sandbox
- 25
- Refused as
global-rate
- Live
- 25
- Sandbox
- 25
- Refused as
endpoint-rate
- Live
- 50
- Sandbox
- No limit
- Refused as
global-concurrency
- Live
- 100
- Sandbox
- 25
- Refused as
global-rate
- Live
- 25
- Sandbox
- 25
- Refused as
endpoint-rate
- Live
- 2,00020 × 100
- Sandbox
- 50020 × 25
- Refused as
global-rate
- Live
- No limit
- Sandbox
- No limit
- Refused as
- Not limited
Publishable keys
Your publishable key, the one a browser sends, has budgets of its own, apart from your secret keys'. They are counted per client address. One client flooding the key spends only its own budget.
- Per client: the same requests per second across every operation as a secret key of that environment (100 in live, 25 in a sandbox), and 25 a second on any one operation.
- Across all clients: a ceiling of twenty times that per-second total.
- In flight: no limit.
Budgets of one operation
A few operations also have a budget of their own, on top of the environment's:
- Budget
- 30 quotes a minute.
- Counted per
- Workspace
- Budget
- 30 pings a minute.
- Counted per
- Secret key
- Budget
- One retry of a settlement every five minutes. A sooner retry returns
429settlement_retry_too_soon. - Counted per
- Settlement
- Budget
- A per-minute budget on each helper, and an hourly simulation budget.
- Counted per
- Secret key, per helperSandbox, for simulations
Headers
Every response a rate budget counted tells you where you stand. It carries the IETF rate-limit fields (opens in a new tab) for the budget nearest to running out:
The in-flight limit isn't a rate, so the fields never describe it on a request that goes through. They do on a 429 refused for it: RateLimit-Limit is the limit, RateLimit-Remaining is 0, and RateLimit-Reset and Retry-After are both 1.
Past the limit
Once you spend a budget, the API returns 429 rate_limited with two headers:
Retry-After(opens in a new tab): the seconds until your next attempt is counted. Wait at least this long before you retry.Stridge-Rate-Limited-Reason: the limit you hit.
rate_limited, with the limit in Stridge-Rate-Limited-Reasonrate_limitedReason global-raterate_limitedReason endpoint-raterate_limitedReason global-concurrencyRetry-After is 1.429 responses, with Retry-After but no Stridge-Rate-Limited-Reason429 before its credential is checked, with Retry-After and the RateLimit-* fields.A 429 is never stored under an Idempotency-Key, so a retry with the same key after Retry-After runs normally. See Idempotency.
async function send(request, attempts = 5) {
for (let attempt = 1; ; attempt++) {
// The clone keeps the request's Idempotency-Key, so a retry is safe.
const res = await fetch(request.clone());
if (res.status !== 429 || attempt === attempts) return res;
const seconds = Number(res.headers.get("Retry-After") ?? "1");
const jitter = Math.random() * 500;
await new Promise((resolve) => setTimeout(resolve, seconds * 1000 + jitter));
}
}Staying under
- Back off. Retry a
429afterRetry-After, with jitter, rather than at once. - Page, don't fetch one by one. A batch job that reads many objects pages through a list instead of fetching each object.
- Listen instead of polling. Webhooks tell you when an object changes. Poll only as a fallback.
- Plan shared capacity. Every secret key of an environment draws on the same budget. Give separate services separate keys for least privilege, and pace their combined traffic.