All error codes

rate_limited

HTTP 429 Too many requests

What happened

Too many requests: the per-token allowance for the current minute (120 reads or 20 writes) is used up or one address sends too much at once, or the shared object storage pool is full; nothing was done. Most often it is the per-token allowance. The count is per token, not per project, and starts over at the top of each minute; all account keys of one account share one allowance for all its projects (partner accounts may have a larger one - RateLimit-Limit shows it). The same refusal, without the RateLimit headers and with Retry-After: 1, comes when one address sends too many requests at once - more than about 120 in a burst, then more than 4 a second - or has more than 20 requests in progress at the same time. The third limit is not yours: object storage endpoints - GET /v1/project/costs with an object storage token included - share a small pool on the platform side for all customers, and while it is full - usually because the storage is answering slowly - an object storage request is refused with Retry-After: 5 and a detail saying nothing was done. Such a refusal still counts against the per-token allowance, like every request that reached the rate limit check; its RateLimit-Remaining is above zero, which tells it apart from a used-up allowance.

What to do

Wait the number of seconds given in the Retry-After header, then send the same request again. If you hit this steadily, pace your calls by the RateLimit-Remaining header or spread them out. Splitting the work across several tokens helps with the per-token budget, not with the per-address limit: every token calling from one address shares its 4 requests a second. A refusal from the object storage pool passes by itself: wait the Retry-After seconds and send the same request again, with the same idempotency key - nothing was started.

Retrying

The request itself is fine. Repeat it later. After a 5xx to a write request, read the resource first and repeat with a new idempotency key - the operation may have started - unless this page or the detail of the response says nothing was started or changed; then, as after a 409 or a 429, repeat the request as it is.

How it arrives

{
    "type": "https://docs.fiberax.com/errors/rate_limited",
    "title": "Too many requests",
    "status": 429,
    "code": "rate_limited",
    "request_id": "a277dcd1ca652c65"
}

Branch your code on code, never on the wording of title.