Platform
Rate limits
Per-key request limits, the 429 response and how to back off.
Rate limits protect the service and every organization using it. They are generous for normal use: an integration driven by webhooks makes a handful of requests per session.
Limits
| Limit | Default | Applies to |
|---|---|---|
| All requests | 120 per minute | Each secret key |
Session creation (POST /sessions) | 20 per minute | Each secret key |
- Limits are counted per key, in one-minute windows. Two services with separate keys do not affect each other.
- A request made with an upload token has no key of its own. It counts against the “all requests” limit of the secret key that created the session.
- Rejected requests count towards the window, so tight retry loops make things worse.
- If your volume needs higher limits, for example many kiosks starting sessions at opening time, ask us to raise them for your organization.
When you exceed a limit
The request is rejected with 429 and the code rate_limited. The Retry-After header gives the number of seconds until the request can succeed.
HTTP/1.1 429 Too Many Requests
Content-Type: application/problem+json
Cache-Control: no-store
Retry-After: 12
{
"type": "https://aimedintake.com/docs/errors#rate_limited",
"title": "Rate limit exceeded",
"status": 429,
"code": "rate_limited",
"detail": "Retry after the number of seconds in the Retry-After header.",
"request_id": "req_01JDKD2Y7Z"
}Wait for that long, then retry. A request rejected for rate limiting has had no effect.
async function request(url: string, options: RequestInit, attempt = 0): Promise<Response> {
const response = await fetch(url, options);
if (response.status !== 429 || attempt >= 5) return response;
const retryAfter = Number(response.headers.get('Retry-After') ?? 1);
const jitter = Math.random() * 0.5;
await new Promise((resolve) => setTimeout(resolve, (retryAfter + jitter) * 1000));
return request(url, options, attempt + 1);
}Staying within limits
- Use webhooks, not repeated requests. Fetch a result once, when
session.completedarrives. - Sync by change. Page through
updated_sincewith a largelimitinstead of fetching sessions one at a time. - Create sessions on demand. Create a session when the patient is ready to start. Credentials are short-lived, so creating in bulk ahead of time wastes both.
- Store what you read. Results do not change; read them from your own copy.
- Add jitter. When many devices start at once, spread their first request over a few seconds.