Rate Limits
Understanding API rate limits and how to handle them.
Default Limits
| Endpoint | Limit | Window |
|---|---|---|
POST /api/emails | 100 requests | per minute |
GET /api/emails | 300 requests | per minute |
POST /api/templates | 60 requests | per minute |
| All other endpoints | 60 requests | per minute |
Rate Limit Headers
Every response includes headers to help you track your usage:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed in the window |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when the window resets |
Rate Limit Exceeded
When you exceed the rate limit, you'll receive a 429 Too Many Requests response:
{
"error": "Rate limit exceeded",
"retryAfter": 45
}The retryAfter field indicates seconds until you can retry.
Best Practices
- Implement exponential backoff when retrying failed requests
- Monitor rate limit headers to avoid hitting limits
- Batch operations where possible instead of many individual calls
- Use webhooks for delivery status instead of polling
- Cache responses when fetching the same data repeatedly
Retry Logic Example
async function sendWithRetry(email, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
const response = await fetch('https://getmailer.co/api/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify(email)
});
if (response.status === 429) {
const data = await response.json();
const waitTime = (data.retryAfter || Math.pow(2, i)) * 1000;
await new Promise(r => setTimeout(r, waitTime));
continue;
}
return response.json();
}
throw new Error('Max retries exceeded');
}Increasing Limits
If you need higher rate limits for your use case, please contact us to discuss your requirements.