Skip to main content

Rate limits and backoff

A limit attaches to the credential, not to the connection. Ten callers behind one API key share that key's allowance. Two keys on the same server never touch each other's.

What a 429 returns​

429 Too Many Requests
HTTP/1.1 429 Too Many Requests
content-type: application/problem+json
retry-after: 12
x-ratelimit-remaining: 0

{
"type": "https://api.bludhavenpets.com/errors/rate-limited",
"title": "Rate Limited",
"status": 429,
"detail": "The credential exceeded its window. Retry in 12 seconds.",
"instance": "/animals"
}
HeaderMeaning
Retry-AfterSeconds to wait before the next attempt
X-RateLimit-RemainingRequests left in the current window, which reads 0 here

Retry-After is the server's own answer. Obey it instead of guessing a delay, because a fixed sleep either wastes time or misses the refill.

Published allowances​

Credential classWindowRequests
POS register keyRolling minute300
Server job keyRolling minute120
Partner bearer tokenRolling minute120
Adopter session tokenRolling minute60

The 429 is authoritative. Treat the table as a planning guide and the header as the fact.

Why a register hits the limit​

A register syncing inventory after every sale burns its allowance on a busy Saturday. Three habits keep it under.

  • Batch inventory writes at the end of a transaction instead of one call per scan.
  • Poll GET /retail/inventory on a timer. A register that polls per screen focus multiplies its own traffic.
  • Cache the animal catalog. An adoption floor showing the same ten profiles needs one fetch.

Backoff that works​

Read Retry-After, wait that long, and add a small random offset so a fleet of registers doesn't retry in the same second.

Node.js
async function callWithRetry(request, { attempts = 4 } = {}) {
for (let attempt = 1; attempt <= attempts; attempt += 1) {
const response = await request();
if (response.status !== 429) return response;

const retryAfter = Number(response.headers.get('retry-after') ?? attempt * 2);
const jitter = Math.floor(Math.random() * 500);
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000 + jitter));

if (attempt === attempts) return response;
}
}
Python
import random
import time

import requests


def call_with_retry(request, attempts=4):
for attempt in range(1, attempts + 1):
response = request()
if response.status_code != 429:
return response
retry_after = int(response.headers.get("Retry-After", attempt * 2))
time.sleep(retry_after + random.uniform(0, 0.5))
return response

Both loops return the final 429 rather than raising. A caller that has spent its budget needs the body to log the failure.

Retrying a write​

A 429 means the platform refused the request before it ran. Retrying is safe for GET, PUT, and DELETE.

A POST needs an Idempotency-Key first, or a retry duplicates the original write. POST /refunds requires the header already. Send it on the other writes for the same reason.

What the sandbox does​

The sandbox gateway enforces no quota. It answers every call, so a reader can explore the console without watching a counter. The 429 response exists in the contract, and the production gateway returns it.

A sandbox that throttles its own reviewer teaches nothing about backoff, so the two gateways diverge on purpose.