Rate limits
Limits per plan and per workspace, response headers and best practices.
Limits by plan#
Each token has a number of requests per minute that depends on the workspace’s plan. GET /me returns it in rate_limit.per_minute.
| Plan | Requests per minute and per token |
|---|---|
| Pro | 60 |
| Business | 300 |
| Enterprise | 1,200 |
A plan with no limit by contract (per_minute at null) is still bounded by a very high technical ceiling, so the rate limit headers are always sent.
Workspace limit#
On top of each token’s limit, all the workspace’s tokens together have 2 times that limit. Creating several tokens therefore does not get around the limit.
Whichever limit is reached first triggers the 429.
Rate limit headers#
Every response carries these headers:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | The request limit that applies. |
X-RateLimit-Remaining | The requests remaining, according to the tightest limit (token, workspace or route). |
X-RateLimit-Reset | The moment the window frees up, as a Unix timestamp, for the limit whose X-RateLimit-Remaining is the lowest. |
Retry-After | On a 429: the number of seconds to wait before replaying. |
Beyond the limit, the response is a 429, with code: rate_limited, Retry-After and the X-RateLimit-* headers, whichever limit was reached (plan, workspace or route).
Route-specific limits#
Some routes have a limit of their own, on top of the plan’s limit:
| Route | Limit |
|---|---|
GET /qr-codes/{qrCode}/export | 20 per minute and per token; 2 times that limit for all the workspace’s tokens. |
POST /webhooks | 20 per minute. |
PATCH /webhooks/{webhook} | 20 per minute per account, a counter shared with the application. Every request that carries url counts, even with the current value; requests without url do not. |
POST /webhooks/{webhook}/test | 10 per minute. |
POST /webhooks/{webhook}/deliveries/{delivery}/resend | 30 per minute. |
Each route limit has its own counter. Creation, test and resend are counted per token creator: two tokens of the same user share it.
Failed authentication#
Refused authentications (401) are also counted per IP address, before any token lookup. Only refusals count: beyond 30 refusals per minute, each further refusal answers 429 rate_limited, with Retry-After, until the minute ends.
A valid token coming from the same address is still accepted. An IPv6 address is counted per /64 block: addresses in the same block share the counter.
A script that loops with a wrong token therefore blocks itself: stop at the first 401 instead of retrying.
Best practices#
- Watch
X-RateLimit-Remainingand slow down before it reaches zero. - On a 429, wait
Retry-Afterseconds before replaying, with a bounded number of attempts. - Smooth your calls with a queue rather than sending bursts.
- Prefer
POST /short-links/bulkto a loop of creations, and webhooks to regular polling. - Keep the QR code images you export: every export is rendered on demand.
const MAX_ATTEMPTS = 5
async function requestWithRetry(url, options) {
for (let attempt = 1; ; attempt += 1) {
const response = await fetch(url, options)
if (response.status !== 429 || attempt === MAX_ATTEMPTS) {
return response
}
await response.body?.cancel()
const retryAfter = Number(response.headers.get('Retry-After'))
const seconds = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter : 2 ** attempt
await new Promise((resolve) => setTimeout(resolve, seconds * 1000))
}
}
const response = await requestWithRetry('https://api.hyllo.fr/api/public/v1/short-links?per_page=15', {
headers: {
Authorization: `Bearer ${process.env.HYLLO_API_TOKEN}`,
Accept: 'application/json',
},
})
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`)
}
console.log((await response.json()).meta.total)
