How to handle Sent API rate limits
This guide shows you how to keep an integration running smoothly under the Sent API v3 rate limits: recover from 429 responses, watch for limit pressure, and shape your own traffic so batch jobs and bursts stay under the account limit. It assumes you can already send authenticated requests; for the limit values and window semantics, see the Rate Limits reference.
Rate limits apply per customer account (10,000 requests per minute for standard endpoints), so every strategy below operates at the account level, not per API key.
Back off and retry on 429
When a request returns 429 Too Many Requests, wait the number of seconds in the Retry-After header before retrying. Fall back to exponential backoff if the header is absent:
async function makeRequestWithRetry(
url: string,
options: RequestInit,
maxRetries = 3
): Promise<Response> {
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('Max retries exceeded');
}
// Get retry delay from header or use exponential backoff
const retryAfter = response.headers.get('Retry-After');
const delay = retryAfter
? parseInt(retryAfter) * 1000
: Math.pow(2, attempt) * 1000;
console.log(`Rate limited. Retrying after ${delay}ms...`);
await sleep(delay);
}
throw new Error('Unreachable');
}
function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}If the retried request is a mutation (POST, PUT, PATCH), send an Idempotency-Key so the retry can't duplicate the operation. See How to retry Sent API requests safely.
Monitor 429 responses as a pressure signal
The API sends the X-RateLimit-* headers only on 429 responses, so there is no per-request quota readout to poll. Treat each 429 as the signal instead: count them in your metrics and alert when they occur, using the headers on the rejection to log when capacity returns:
async function makeRequest(url: string, options: RequestInit): Promise<Response> {
const response = await fetch(url, options);
if (response.status === 429) {
const limit = response.headers.get('X-RateLimit-Limit');
const reset = response.headers.get('X-RateLimit-Reset');
console.warn(
`Rate limited: limit ${limit}/min, window resets at ${new Date(parseInt(reset!) * 1000)}`
);
// Send to your monitoring system
// metrics.increment('api.rate_limited', { limit });
}
return response;
}A sustained 429 rate means your steady-state traffic exceeds the account limit. Throttle client-side (next section) or contact support@sent.dm about a higher limit.
Throttle requests client-side
To avoid hitting the limit at all, space out requests at the source. Most integrations never need this – at 1,000 recipients per POST /v3/messages the standard limit accepts 10 million messages a minute. Reach for a throttle when a fan-out job can burst past 10,000 requests in a minute. Pacing at 150 requests per second keeps you at 9,000 requests per minute, under the 10,000/minute standard limit:
class RateLimiter {
private minInterval: number;
private lastRequestTime: number = 0;
constructor(requestsPerSecond: number) {
this.minInterval = 1000 / requestsPerSecond;
}
async throttle(): Promise<void> {
const now = Date.now();
const timeSinceLastRequest = now - this.lastRequestTime;
if (timeSinceLastRequest < this.minInterval) {
const delay = this.minInterval - timeSinceLastRequest;
await sleep(delay);
}
this.lastRequestTime = Date.now();
}
}
function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Use: limit to 150 requests per second (9,000/min, under the 10,000 limit)
const limiter = new RateLimiter(150);
async function makeThrottledRequest(url: string, options: RequestInit): Promise<Response> {
await limiter.throttle();
return fetch(url, options);
}If several workers share one account, budget the limit across them: for example, four workers at 40 requests per minute each. Every API key on the account draws from the same pool.
Cache responses and pace batch work
Two ways to reduce the requests you send in the first place: cache reads you would otherwise repeat, and process bulk workloads in paced batches instead of all at once.
// ❌ Inefficient: unpaced individual requests (100 API calls at once)
for (const contact of contacts) {
await createContact(contact);
}
// ✅ Efficient: cache repeated reads, process writes in paced batches
class CachedContactClient {
private cache = new Map<string, Contact>();
async getContact(id: string): Promise<Contact> {
// Return cached result if available
if (this.cache.has(id)) {
return this.cache.get(id)!;
}
const contact = await fetchContact(id);
this.cache.set(id, contact);
return contact;
}
async batchProcessContacts(
contacts: Contact[],
batchSize: number = 10
): Promise<void> {
// Process in batches with rate limiting
for (let i = 0; i < contacts.length; i += batchSize) {
const batch = contacts.slice(i, i + batchSize);
// Process batch concurrently
await Promise.all(
batch.map(contact => this.processContact(contact))
);
// Wait between batches
if (i + batchSize < contacts.length) {
await sleep(1000);
}
}
}
private async processContact(contact: Contact): Promise<void> {
// Implementation
}
}
function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}A single POST /v3/messages request accepts multiple recipients, so sending to a list is one request, not one per recipient. For high-volume sending patterns, see the Batch Operations guide.
If you cache responses, remember that message and contact state changes server-side. Prefer webhooks over polling for status updates, and expire cached reads accordingly.
Verify your handling
You have working rate-limit handling when:
- A
429response results in a delayed retry that succeeds, not a failed operation. - Your metrics show 429 counts, and a sustained increase triggers an alert.
- Batch jobs complete without producing 429 bursts, because throttling and pacing keep steady-state traffic under 10,000 requests per minute.
Related
- Refer to the Rate Limits reference for limit values, window semantics, and the 429 response format.
- How to retry Sent API requests safely
- How to handle Sent API errors
How to retry Sent API requests safely
Retry Sent API v3 requests without duplicating messages or contacts: derive stable idempotency keys, reuse them across retries, and resolve conflicts.
Testing & Debugging
Test and debug your Sent integration by validating sends with sandbox mode, unit-testing webhook handlers, verifying signatures, and tracing failures.