Rate Limits
How many requests a key may send each minute, the headers that say where you stand, and what to do at the limit.
The limits
Each key has two limits, counted over a sliding minute:
| Limit | Applies to |
|---|---|
| 300 requests a minute | Every call the key makes |
| 30 requests a minute | Calls that need studies:write, reports:write, insights:write, chat:write or auto:write, the scopes that spend credits, including the calls in them that spend nothing, such as cancelling a study or making a share link. Such a call counts against the 300 too |
The limits are per key (for an app connected through OAuth, per connection), so two systems with their own keys never slow each other down. They are separate from the workspace's daily limit, which caps the credits API keys may spend in a day (see Authentication).
The headers
Every answer to a call that passed the key, permission and IP checks says where the key stands, for the limit the call counted against. A refusal before that point (a 401, a 403, ip_not_allowed) and a replayed idempotent answer carry none of these headers:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | The limit: 300, or 30 for a call that spends (300 when such a call was refused by the 300 limit) |
X-RateLimit-Remaining | Requests left in the current minute |
X-RateLimit-Reset | When the oldest request in the window leaves it, in Unix seconds |
At the limit
A call over the limit is refused with 429 rate_limited and a Retry-After header with the seconds to wait. Nothing was done and nothing was charged. Wait that long, then send fewer requests: poll a study every 15 seconds or so, or use webhooks instead of polling.
If iMario cannot count requests for a moment, calls are refused with 503 temporarily_unavailable and a Retry-After header, rather than let through unmetered. Retry after the wait; a POST with an Idempotency-Key is safe to send again.
Requests without a working key
An address that sends 30 requests in a minute without a working key (no key, or one that is unknown, revoked or expired) is refused for the rest of that minute with 429 too_many_auth_failures and a Retry-After header, whatever key its next requests carry. Requests with a working key are never counted, so a key mistyped now and then does not come near it. An IPv6 address is counted with its /64. If you see this code, check the key your code sends before retrying.