Rate limits
Rate limits keep QHR fast for everyone. They are generous for normal integrations; you will only meet them if you send many requests in a short burst.
The limits
| Limit | Applies to | Allowance |
|---|---|---|
| Per token | Each API token | 120 requests per minute |
| Per network address | All requests from one IP address to the Open API | 600 requests per minute |
| Failed sign-ins | Requests with a wrong, expired or revoked token from one IP address | 30 per minute, then that address is blocked for 5 minutes |
A few heavy operations, such as government (GOSI) lookups and support requests, also have their own per-company limits, the same ones that apply in the web app.
When you hit a limit
QHR answers with 429 Too Many Requests, a Retry-After header and the usual error body:
http
HTTP/1.1 429 Too Many Requests
Retry-After: 23
Content-Type: application/json
{ "error": "Too many requests", "code": "rate_limited" }
Retry-After is the number of seconds to wait. Pause for that long, then continue. Requests sent before then are refused and still count against you.
Staying within the limits
- Use the largest page size a list allows. A bigger
per_pagefetches the same data with fewer calls. See Pagination. - Don't poll in a tight loop. If you sync data, sync on a schedule (every few minutes is plenty) rather than continuously.
- Spread out bulk jobs. When updating hundreds of records, send them one after another rather than all at once. Two requests per second stays well under the per-token limit.
- Cache what rarely changes, such as departments, leave types and roles.
- Fix bad tokens quickly. Repeated
401responses from a misconfigured server count as failed sign-ins and can block your whole IP address for 5 minutes, including your other, valid tokens.
Example: respecting Retry-After
python
import os, time, requests
def qhr_get(url, **kwargs):
headers = {"Authorization": f"Bearer {os.environ['QHR_TOKEN']}"}
for attempt in range(5):
res = requests.get(url, headers=headers, timeout=30, **kwargs)
if res.status_code != 429:
return res
time.sleep(int(res.headers.get("Retry-After", "30")))
raise RuntimeError("Still rate limited after 5 attempts")