Handle rate limits and server errors
Back off after 429 responses and retry safe operations carefully after temporary server failures.
Updated
Handle a 429 response
A rate-limited request returns 429 Too Many Requests with detail.status set to rate_limit_exceeded. Read the response headers before retrying:
Retry-Aftergives the minimum wait in seconds for a rejected request.X-RateLimit-Limitreports the bucket limit.X-RateLimit-Remainingreports the remaining requests.X-RateLimit-Resetreports when the bucket resets.
Wait for Retry-After, then retry with exponential backoff and jitter. Reduce parallel requests and queue work instead of sending a burst as soon as the window resets.
Handle server errors
For a 500 response, the public body contains a generic error and a request_id; internal exception details are not returned. A 503 can indicate that a required service is temporarily unavailable.
Retry read-only requests with a bounded backoff. Before retrying a create, update, payment, or other state-changing request, determine whether the first attempt completed. A timeout or 5xx response does not prove that a mutation failed, and an immediate repeat can duplicate work.
Preserve diagnostics
Record the timestamp, method, path, status, response body, and X-Request-Id. Never log the x-api-key value. Stop automatic retries after a small bounded number of attempts and surface the failure for review.
Related articles
Diagnose 401 and 403 responses from API key authentication and authorization checks.
Use a 422 response to find the invalid field and correct the request shape or value.
Create a scoped API key, copy its secret once, and revoke it when it is no longer needed.