Introduction
Rate Limits
Understanding API rate limits
The API uses rate limiting to ensure fair usage and maintain performance for all users. Rate limits are applied per organization.
Rate Limit Headers
Every response includes headers showing your current rate limit status:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed |
X-RateLimit-Remaining | Requests remaining in current window |
Retry-After | Seconds to wait before retrying (only on 429 responses) |
When You're Rate Limited
If you exceed the rate limit, the API returns a 429 Too Many Requests response:
{
"error": "Rate limit exceeded"
}The Retry-After header tells you how many seconds to wait before making another request.
Handling Rate Limits
Implement retry logic with exponential backoff to handle rate limiting gracefully:
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status !== 429) {
return response;
}
if (attempt === maxRetries) {
throw new Error('Rate limit exceeded after max retries');
}
const retryAfter = response.headers.get('Retry-After') || '1';
const waitSeconds = parseInt(retryAfter, 10);
await new Promise(resolve =>
setTimeout(resolve, waitSeconds * 1000)
);
}
}