Rate Limits
API rate limiting information and best practices
Overview
The SafePays API V2 applies rate limits per API key to ensure stability and fair usage for all users.
If you consistently hit rate limits, optimize your implementation or contact support to discuss higher limits.
Current Limits
| Window | Limit |
|---|---|
| Per minute | 1,000 requests per API key |
| Per hour | 10,000 requests per API key |
Rate Limit Exceeded
When you exceed the rate limit, you'll receive a 429 Too Many Requests response:
{
"error": "Rate limit exceeded. Please retry after 60 seconds."
}Best Practices
Implement Exponential Backoff
When rate limited, wait and retry with increasing delays:
async function requestWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (error.status === 429) {
const delay = Math.min(1000 * Math.pow(2, i), 30000);
await new Promise(resolve => setTimeout(resolve, delay));
} else {
throw error;
}
}
}
throw new Error('Rate limit exceeded after retries');
}Cache GET Responses
Cache responses from GET endpoints (/api/v2/customer/\{id\} and /api/v2/invoice/\{id\}) to reduce repeated calls for the same data.
Batch Operations
When creating multiple invoices, space out requests instead of sending them all at once. A small delay (100–200ms) between requests helps stay within limits.
Requesting Higher Limits
If you need higher limits for your use case, contact support@safepays.com with:
- Your use case description
- Current usage patterns
- Expected request volume
FAQ
Are rate limits per API key or per account? Rate limits are applied per API key. Each key has its own independent limit.
Do failed requests count against the limit? Yes, all requests count regardless of whether they succeed or fail.
Are webhooks affected by rate limits? No. Webhook deliveries from SafePays to your server are not subject to your API rate limits.