OTP SMS delay: causes and fixes
An OTP SMS delay is a code that does arrive, but late enough to matter: after the user gave up, pressed resend, or after the code expired. Delay can build up in your own server, in retries, at the API, on the operator's route or on the handset, so measure where it happens before you change anything. The fixes that help most are on your side: send once with an Idempotency-Key, show a resend timer, tell users to use the latest code, turn on autofill and offer WhatsApp, whether you send on your own DLT template or with OTP without DLT.
By Vivek Singh, Founder, Diorbit TechnologiesUpdated
What counts as a late OTP?
This guide is about codes that arrive late. If the code never arrives at all, start with OTP not received in India, which covers number format, rate limits, template mismatches and phone settings.
"Late" is not a fixed number of seconds. It is late when it breaks the user's flow. On DiOTP a code expires 5 minutes after it is sent, and the resend button can be pressed again after 30 seconds. That gives three useful lines:
- Late for the user: the code has not arrived by the time the resend timer runs out, so the user starts to doubt it and presses resend.
- Late for the flow: a second code was requested, and now two codes arrive close together. The user may type the older one.
- Too late to use: the code arrives after its 5 minute expiry. The verify call returns 410 expired, and the user has to ask for a new one.
We do not publish delivery times. They depend on the operator's network and the user's handset, which neither you nor any provider fully controls. What you can do is measure your own flow and design it so that a slow message does not become a failed login.
Where can an OTP SMS delay happen?
An OTP goes through five places between the button press and the phone. Each one can add time, and each one needs a different fix.
1. Your own server and queue
Many apps put the send call on a background job queue. If the queue is busy with other work, such as emails, reports or image processing, the OTP waits in line before your server even calls the API. The user sees this as a slow SMS, but the message has not been sent yet. Send OTPs from the request itself, or from a separate, short queue that only handles OTPs.
2. Retries that send two codes
If your HTTP client times out and retries the send, and you did not pass an Idempotency-Key header, the retry is a new request and can send a second code. The user then gets two codes, possibly far apart, and only the latest request_id is in your session. On DiOTP, send one Idempotency-Key per user action. A retried request with the same key returns the first result instead of sending or charging again. Using the same key with a different request body returns 409 idempotency_key_reused.
3. The API
The send call returns as soon as the request is accepted, with a request_id and an expires_at time. If it returns 503 sending_unavailable, nothing was sent and nothing was charged; wait a short time and retry with the same Idempotency-Key, with exponential backoff. If it returns a 429, a rate limit stopped the send, and retrying straight away will not help.
4. The operator's route
Once the message leaves the provider, it travels over the operator network to the user's SIM. Network load and the user's operator can affect how long that takes. This part is outside your code, which is why a second channel matters.
5. The handset
- Weak signal. The message waits on the network until the phone has coverage again.
- Roaming. A phone roaming abroad may get Indian SMS late, depending on its plan and the network it is on.
- Airplane mode, a switched-off second SIM or a phone that is out of service. The message is held until the SIM is reachable.
DND is not a cause of late OTPs. Do Not Disturb is for promotional messages, and a correctly registered OTP is not promotional. If you see delays only on DND numbers, check the template category instead.
How do you find where an OTP SMS delay happens?
You cannot fix a delay you have not measured. You do not need a delivery report for this; two timestamps you already control tell you most of the story.
- Log the time the user pressed "Send code", on your server, with the user's session.
- Log the time just before you call POST /v1/otp/send, and the time the response came back, with the request_id. The gap between step 1 and this one is your own queue.
- Log the HTTP status and error code of every send. Count how often you see 429, 503 or a retry, and check that every retry reused its Idempotency-Key.
- Log the time the user submits the code to your verify endpoint, with the same request_id, and the verify result.
- Work out the time from your send call to the user's submit for each successful login. This includes delivery, the user reading the message and typing it, so treat it as an upper bound, not a delivery time.
- Look at the slow cases. Group them by hour of day and by how often the user pressed resend. If slow cases cluster around your busy hours, look at your queue first.
- Count verify results of 410 expired and 400 invalid_code that come right after a resend. These are often users typing an older code.
- Change one thing at a time, such as the queue, the retry logic or the resend timer, and compare the same numbers a week later.
Keep the code itself out of these logs. On DiOTP it is generated and stored by the API and your server never sees it, so the request_id is the only key you need. The OTP security best practices guide covers what else to keep out of logs.
Which screen design hides OTP delays?
Much of what a user feels as delay is what the screen tells them while they wait. A good waiting screen turns a slow message into a short pause instead of a support ticket.
- Show a visible resend timer that matches the 30 second cooldown. If the button is live before the API will accept a resend, the user gets a 429 resend_cooldown and thinks the system is broken.
- After a resend, say "We sent a new code. Use the latest one." The old code belongs to the old request_id, so typing it against the new one fails.
- Show the number you sent to, with an "Edit number" link. A typo looks exactly like a long delay.
- Keep the code field and its contents if the user switches apps to read the SMS, so they do not have to start again.
- If the user waits past the expiry, show a clear "This code has expired. Send a new one." message on a 410, not a generic error.
- Tell users how many tries they have. After 5 wrong attempts the verify call returns 429 too_many_attempts, and they need a new code.
Turn on autofill
Autofill saves the user from switching apps, which is often where the real time goes. On the web and iOS, autocomplete="one-time-code" or textContentType = .oneTimeCode reads the code from any SMS that contains it, so it works with the shared template. On Android, the SMS User Consent API works with the shared template in one tap. The SMS Retriever API needs your own template with your app hash. The OTP autofill guide for Android and iOS has the code.
When should you offer WhatsApp for slow OTPs?
WhatsApp OTPs travel over mobile data or Wi-Fi, not the SMS network. That helps the users most likely to see late SMS: people roaming abroad on Wi-Fi, or in places with data but poor SMS reception.
On DiOTP, WhatsApp OTP is on the same API: send with channel set to whatsapp. It is enabled per account; if it is not, the send returns 409 channel_not_enabled. A simple pattern is SMS first, then a "Send on WhatsApp instead" button that appears when the resend timer ends. That way you are not sending two channels at once, and the user picks the one that works for them. The WhatsApp OTP authentication template guide covers the message.
Send the next code on WhatsApp
{"to":"9876543210","country_code":91,"channel":"whatsapp","purpose":"login"}What should you not do about OTP delays?
- Do not let users press resend in a loop. Each extra code adds confusion and runs into the hourly limit of 3 codes per number.
- Do not retry a send without an Idempotency-Key. You may text the user twice and pay twice.
- Do not lengthen the life of a code in your own app to cover delays. The API decides expiry, and a longer window makes guessing easier.
- Do not blame DND. It does not delay a correctly registered OTP.
- Do not quote delivery times to your users. You cannot control the network, so promise a resend option instead.
Questions and answers
Why does my OTP SMS arrive late?
The delay can come from your own server queue, from a retried request that sent a second code, from the operator's route, or from the phone itself: weak signal, roaming or a SIM that is out of service. Measure your own send times first.
How long is an OTP valid on DiOTP?
Five minutes from the send. After that the verify call returns 410 expired and the user needs a new code.
Does DND delay OTP messages?
No. DND is for promotional messages. A correctly registered OTP is not promotional, so DND does not delay it.
Why did my user get two OTPs?
Either they pressed resend, or your server retried a send that timed out without an Idempotency-Key. Send one Idempotency-Key per user action so a retry returns the first result instead of a second code.
How long should the resend timer be?
Match it to the API's cooldown. DiOTP allows one code to a number every 30 seconds, so a 30 second timer means the resend button only works when a new code can actually be sent.
How do I measure OTP delay without delivery reports?
Log the time of your send call and the time the user submits the code, both with the request_id. The gap is an upper bound that includes delivery and typing, and it shows you which cases are slow.
