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.
Rate budgets in a live environment and in a sandbox
Secret keysOne budget per environment, shared by every secret key of it.
Requests per second across every operation
Live
100
Sandbox
25
Refused as
global-rate
Requests per second on any one operation
Live
25
Sandbox
25
Refused as
endpoint-rate
Requests in flight at once
Live
50
Sandbox
No limit
Refused as
global-concurrency
A publishable keyOne budget per client address, apart from your secret keys'.
Requests per second across every operation
Live
100
Sandbox
25
Refused as
global-rate
Requests per second on any one operation
Live
25
Sandbox
25
Refused as
endpoint-rate
Requests per second across all its clients
Live
2,00020 × 100
Sandbox
50020 × 25
Refused as
global-rate
Requests in flight at once
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:

Operations with a rate budget of their own
Quote a routed payoutPOST/v2/payouts/quotes
Budget
30 quotes a minute.
Counted per
Workspace
Ping a webhook endpointPOST/v2/webhook-endpoints/{endpoint_id}/ping
Budget
30 pings a minute.
Counted per
Secret key
Retry a settlementPOST/v2/settlements/{id}/retry
Budget
One retry of a settlement every five minutes. A sooner retry returns 429 settlement_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 rate-limit fields on a counted response
RateLimit-Limit: 25
The budget's size, in requests per window.
RateLimit-Remaining: 24
What is left of the budget after this request.
RateLimit-Reset: 1
Seconds until the window ends and the budget refills.

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.
Every 429 response and what ran out
A rate budget ran out: rate_limited, with the limit in Stridge-Rate-Limited-Reason
rate_limitedReason global-rate
Requests per second across every operation.
rate_limitedReason endpoint-rate
Requests per second on this one operation, or the operation's own budget.
rate_limitedReason global-concurrency
Requests in flight at once, in live. A slot frees as soon as one of them completes, so Retry-After is 1.
Other 429 responses, with Retry-After but no Stridge-Rate-Limited-Reason
Too many refused credentials: more than 100 in a minute from one client address. Its next request returns 429 before its credential is checked, with Retry-After and the RateLimit-* fields.
The sandbox's hourly simulation budget; see Sandbox.
A settlement retried less than five minutes after its last retry.

A 429 is never stored under an Idempotency-Key, so a retry with the same key after Retry-After runs normally. See Idempotency.

Retry a 429 after Retry-After, with jitter
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 429 after Retry-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.