Skip to content
Docs

Rate limits

Reading limit responses

Use x-ratelimit-* and Retry-After together with error.retryable.

Overview

Successful and throttled responses may include standard rate-limit headers. On 429, also read retry-after.

FieldRequiredDescription
x-ratelimit-limitNoMax requests in the current window for the applied bucket
x-ratelimit-remainingNoRequests left before the next 429 from this bucket
x-ratelimit-resetNoUnix timestamp (seconds) when the window resets
retry-afterNoSeconds to wait (set when status is 429)

JSON body

json
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please retry shortly.",
    "retryable": true
  }
}

Client snippet

javascript
const res = await fetch(url, { headers });
const limit = res.headers.get("x-ratelimit-limit");
const remaining = res.headers.get("x-ratelimit-remaining");
const reset = res.headers.get("x-ratelimit-reset");
if (res.status === 429) {
  const retryAfterSec = Number(res.headers.get("retry-after") || "1");
  // sleep retryAfterSec, then retry
}

Always branch on error.code as well—some rate-limit responses may omit headers. See Rate limit errors.