Rate limits

When the Roots API answers 429, and how to retry.

A 429 has two causes: a request budget per client IP address, and a per-resource lock that stops two operations racing on the same account or counterparty.

Request budget

Requests are counted per client IP address: one budget of 600 requests per rolling 60 seconds, shared across all endpoints. A request over it is a 429 with code rate_limited and a Retry-After header giving the seconds to wait.

Per-resource locks

RequestLocks429 when
POST /api/v1/transfersThe source account, plus the destination account or counterpartyAny of them already has a transfer or status change in progress.
PATCH /api/v1/accounts/{account_id}The accountA transfer or another status change on that account is in progress.
PATCH /api/v1/counterparties/{counterparty_id} that changes statusThe counterpartyA transfer to that counterparty is in progress.

A lock lasts only as long as the request that holds it, and never more than 60 seconds. Locks do not queue: the second request is refused at once with Retry-After: 1. Resend it with the same Idempotency-Key and body.

{
  "type": "https://docs.roots.finance/docs/errors#rate_limited",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "account acct_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d has a transfer in progress",
  "code": "rate_limited",
  "instance": "/api/v1/transfers",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}

Retry a 429

  1. Wait the number of seconds in the Retry-After header. A lock 429 sends Retry-After: 1.
  2. Back off exponentially with jitter, and cap the number of attempts.
  3. Resend with the same Idempotency-Key and the identical body. If the first request has committed by then, you get its stored response. See Idempotency.
  4. Serialize your own transfers per source account where you can. Parallel transfers from one account collide on its lock.

Build a well-behaved client

  • Bound concurrency per account and per counterparty.
  • Use webhooks instead of polling for status changes.
  • Do not retry 4xx responses other than 429.

Next steps

  • Read Errors for the full list of codes.

Did this page help you?