Rate Limits
Understand API rate limits and how to handle 429 responses.
The Salesly API enforces rate limits to ensure fair usage and system stability.
Limits
| Endpoint Type | Limit | Scope |
|---|---|---|
| Read (GET) | 120 requests/minute | Per API key |
| Write (POST, PUT, DELETE) | 30 requests/minute | Per API key |
Rate Limit Headers
When you exceed the limit, the API returns a 429 Too Many Requests response with a Retry-After header:
{
"error": {
"type": "rate_limit_exceeded",
"message": "Too many requests. Please retry after the period indicated in the Retry-After header."
}
}Retry-After: 42The Retry-After value is the number of seconds to wait before retrying.
Handling Rate Limits
async function apiCallWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status !== 429) {
return response;
}
const retryAfter = parseInt(response.headers.get("Retry-After") || "60");
const delay = retryAfter * 1000;
console.log(`Rate limited. Retrying in ${retryAfter}s...`);
await new Promise((resolve) => setTimeout(resolve, delay));
}
throw new Error("Max retries exceeded");
}Best Practices
- Batch operations — use
/batchendpoints instead of looping single creates - Cache responses — avoid re-fetching data that hasn't changed
- Spread requests — distribute writes over time instead of bursting
- Monitor 429s — track rate limit responses in your application logs
- Use
Retry-After— always respect the header value rather than guessing