How to Handle API Rate Limits Without Losing Messages
By Nimana · Last updated November 16, 2026 · 3 min read
Hit a rate limit and messages can get lost. Learn how to read rate limit headers, retry with exponential backoff, and queue sends so nothing gets dropped.
Why This Matters
Every messaging API limits how fast you can send. It keeps the service stable for everyone, and it protects you from runaway scripts. The limit is not a problem when you plan for it. It becomes a problem on a busy day, when your app fires hundreds of requests at once, the API starts refusing them, and the messages quietly disappear.
A few habits make sure that never happens.
Two Kinds of Limits
It helps to know the difference:
- Rate limits control how fast you can send, for example 60 requests per minute.
- Quotas control how much you can send in a billing period, for example 5,000 emails a month.
You can be well under your quota and still hit a rate limit, if you send everything in one burst.
What a Rate Limit Error Looks Like
When you go over the limit, most APIs return HTTP status 429 Too Many Requests. Good APIs also tell you how long to wait, usually in a Retry-After header. A 429 means "slow down", not "this failed forever". The message is safe to send again later.
Seven Tips for Handling Rate Limits
1. Read the rate limit headers
Many APIs return headers on every response that show your limit, how many requests you have left, and when the window resets. Check them, and slow down before you reach zero instead of waiting for an error.
2. Retry with exponential backoff
When you get a 429, do not retry immediately. Wait, then double the wait on each retry, with a cap. A common pattern is to start at 1 second, double each time, and stop growing at 60 seconds. If the API sends a Retry-After header, use that value instead.
async function sendWithBackoff(url, options, maxRetries = 5) {
let wait = 1000; // start at 1 second
for (let i = 0; i <= maxRetries; i++) {
const res = await fetch(url, options);
if (res.status !== 429) return res;
const retryAfter = Number(res.headers.get('Retry-After'));
const delay = retryAfter ? retryAfter * 1000 : wait;
await new Promise((r) => setTimeout(r, delay));
wait = Math.min(wait * 2, 60000); // double each retry, cap at 60 seconds
}
throw new Error('Still rate limited after retries');
}
3. Put sends in a queue
Do not send messages directly from the moment something happens. Add them to a queue, and let a worker send them at a steady pace below your limit. A queue also keeps messages safe if your app restarts.
4. Spread out bursts
A sale, a launch, or an end-of-month reminder can create thousands of messages in a minute. Spread them over time instead. Customers rarely mind a message arriving ten minutes later, and your sending looks healthier too.
5. Retry only what is worth retrying
A 429 or a 5xx error is worth another try. A 400 or 401 will fail every time, so fix the request instead of retrying it.
6. Make retries safe
If a retry could send the same message twice, use an idempotency key so the API ignores the duplicate. Our guide on retrying failed requests explains how.
7. Limit how often users can trigger sends
If a user can tap "Resend code" over and over, they can burn through your limits on their own. Add a short cooldown in your app, and tell users when to try again.
Watch Your Quota Too
Rate limits work on a sliding window, so your allowance refills continuously. Quotas reset at the start of each billing period. Check your usage before a busy period, because once you pass a quota, requests can be refused until the next period or until you upgrade. For example, SendAPI returns a 402 Payment Required error when you pass your monthly email quota.
How SendAPI Helps
SendAPI makes its limits easy to see and easy to plan for:
- Limits per plan, per API key: 60 requests a minute on Starter, 300 on Growth, 1,000 on Business, and 2,000 on Enterprise
- Rate limit headers on every response (
X-RateLimit-Limit,X-RateLimit-Remaining, andX-RateLimit-Reset), so your code always knows how much room is left - A
Retry-Afterheader on every429, so you know exactly how long to wait - OTP limits per phone number: 5 sends per hour and 20 sends per day, to prevent abuse
- Clear error responses, such as
rate_limit_exceededfor rate limits andemail_quota_exceededwhen you pass your monthly email quota
All of this comes with WhatsApp, SMS, OTP, and email under one API from $9.99 a month.