DEV Community

SunspireValerius59
SunspireValerius59

Posted on

Delayed SMS OTP Delivery: Routing Login Support With Minimal Evidence

Route a B2B SaaS contact form using a small set of verification facts: destination country, sender setup, send attempts, and the last delivery observation. Start with deterministic queue rules. The bill behind a delayed login includes message attempts, delivery checks, retained evidence, and support investigation; uncontrolled resends multiply the first term before they explain the failure. An initial send plus two resends permits three message attempts for one login challenge. That is a workload budget, not a delivery benchmark or a quoted charge.

TL;DR: SMS OTP login codes can arrive late or fail because of carrier filtering, missing sender approval, formatting, and geographic routing differences. For US carriers and EU destinations, check those conditions before treating another send as a repair. A cooldown, a bounded resend policy, and an available fallback factor give the user a recovery path. Keep enough evidence to route their contact form to the right support queue, then delete the sensitive detail when its troubleshooting purpose expires.

The integration question is narrower than choosing a messaging platform: how much delivery evidence must the application collect before it can assign a useful support owner? A ticket containing only “code never arrived” makes every receiving team start over. A ticket carrying an OTP value creates a different problem. Neither is necessary.

What grows when carriers delay SMS OTP delivery?

Treat the attempt budget as the first quantity to control. With one initial send and two permitted resends, the upper bound is three sends per challenge; allowing only one resend lowers that bound to two. Those are illustrative policy choices. Actual charges depend on the service and destination, and these counts say nothing about which attempt will arrive. The practical change is to cap attempts per challenge and enforce the cooldown on the server, so repeated clicks do not keep expanding the work.

Count attempts first.

Don't confuse checking with sending.

Delivery observation has its own multiplier. If a design checks each of three attempts four times, it schedules up to twelve status reads. Again, this is arithmetic for a proposed policy, not measured traffic or a recommended polling interval. Stopping checks after a terminal result, or after the challenge stops being useful, reduces that work. It does not improve the carrier path. Without a measured workload, there is no basis for declaring storage or message charges the largest monetary item; the dominant controllable multiplier here is the number of sends allowed for one unresolved challenge.

Retained evidence grows with attempts too. Keeping a full contact-form body beside every status observation duplicates user text without necessarily helping diagnosis. Prefer a ticket reference that points to a restricted support record. Keep delivery observations separately, with the access and deletion rules their purpose requires. The engineering effort moves from copying everything into a log to maintaining a small, useful relationship between the login challenge, its attempts, and the eventual support request.

This matters because “try again” has two meanings. Rechecking a known attempt asks for evidence. Creating another attempt asks a carrier to deliver another message. A retry controller should distinguish them.

Which evidence gets the contact form to the right queue?

Carrier filtering and aggressive anti-spam controls can delay or block OTP delivery. Missing approved sender or signature setup is another common cause. Formatting and geography also affect reliability. A support form should therefore gather the destination country and a reference to the failed challenge, while the backend attaches the relevant sender configuration reference and available status observations. Do not ask the user to paste the verification code.

Route by the evidence available, with an explicit destination for uncertainty. A confirmed sender-setup issue belongs with the team that owns messaging configuration. Repeated unresolved observations for a destination belong with delivery operations. A user who cannot proceed and needs another factor belongs with account access support. These are proposed ownership rules for the SaaS application, not diagnoses automatically supplied by a provider. If the evidence supports several explanations, assign an owner who can investigate instead of labeling the ticket “carrier blocked.”

Unknown is useful.

For a US destination, inspect sender approval and filtering evidence before escalating to an application login defect. For an EU destination, inspect the actual destination and sender requirements rather than treating the region as one uniform delivery path. Geography is a diagnostic dimension; it is not proof of a particular failure. A late observation cannot establish that the handset displayed the code while it was still valid. Keep the application’s verification outcome distinct from the delivery observation.

The contact form should still work when the user cannot log in. Otherwise the recovery mechanism depends on the very factor that has failed. Let the form create a support request, but require the account-access process to establish identity independently before changing security settings. A user-supplied phone number or ticket reference is routing input, not authorization.

Compare the integration work you will actually own

Twilio SMS, Amazon SNS, and Vonage SMS API are three real alternatives to evaluate. They belong in a comparison because a team may already have an integration with one of them; an existing, understood adapter changes the amount of new work required. Their names alone do not establish that a destination will receive an OTP reliably. For each candidate, check the relevant sender requirements, the delivery evidence available to your application, and the effort required to connect that evidence to support routing.

Option Integration question for this workflow Boundary to test before choosing
Twilio SMS Can the existing SMS integration attach delivery evidence to the support ticket? Validate sender setup and destination behavior for the intended login flow.
Amazon SNS Does an existing SNS integration reduce the work of connecting sends and support ownership? Confirm that the evidence your adapter retrieves is sufficient for the routing rules.
Vonage SMS API Can the team reuse its messaging adapter and operational knowledge? Check destination requirements and how unresolved delivery is represented.
A shared backend API Does discovering a capability reduce the work of building and maintaining another adapter? Account for polling, application abuse controls, and the separately built fallback.

Infrai provides one key, one bill, and a single REST API with no SDK to install. Its self-describing API is the reason to consider it here: public discovery exposes request and response schemas plus runnable examples, so wiring a capability starts with reading one discovery endpoint instead of learning another SDK. A single credential also reduces setup for a team connecting messaging to other backend work. Delivery evidence is retrieved by polling, so the application must schedule those checks; geographic abuse controls and country-based spending cutoffs also remain application responsibilities.

That boundary matters more than a feature count. A team whose contact form already feeds a working Twilio, SNS, or Vonage support process should compare the cost of changing that process against the work discovery actually removes. Conversely, a new adapter can be a sensible choice if its contract is easier for the team to implement and its evidence is sufficient. This is a conditional integration decision. There is no verified comparative delivery benchmark here.

Keep the fallback requirements explicit during evaluation. An email code requires its own verification flow in the shared API option; do not assume a hosted email OTP facility accompanies hosted SMS OTP. A requirement for voice, WhatsApp, RCS, or SMTP relay also changes the shortlist because that option does not provide those channels. The support form still needs a useful destination when no configured fallback is available.

Build a recovery boundary before adding another send

The login challenge should own its expiry and resend allowance. The delivery adapter should own communication with the chosen service. The support router should consume the resulting evidence without needing the OTP secret. These boundaries keep a delayed message from turning into an unrestricted send loop or a ticket full of authentication material.

Enforce cooldowns on the backend. A disabled button alone does not constrain repeated requests. Apply the application's destination-country policy before authorizing a send, and define a spending cutoff for destinations where abuse would create unacceptable exposure. A destination being permitted does not make it reliable; a permitted country still needs the same sender and formatting checks.

Rate-limit handling belongs inside the adapter. On HTTP 429, honor Retry-After when present and use backoff rather than a tight loop. A write retry must preserve the operation's idempotency identity so uncertainty about a response does not create another send. An intentional resend is a separate policy decision. Keep those concepts separate in both the implementation and the support evidence.

Polling needs a stopping rule as well. Check while an observation can change what the application or support team does; stop when the outcome is terminal or the challenge is no longer actionable. Leave the next scheduled observation to a worker rather than making the user hold the contact form open. The form can acknowledge that the request has entered a queue while the backend continues collecting bounded evidence.

Keep the adapter small.

This Python example retrieves one SMS status observation without assuming any undocumented response fields. Set INFRAI_API_BASE to the configured API base ending in /v1, INFRAI_API_KEY to your credential, and SMS_MESSAGE_ID to an existing message identifier. It performs at most three HTTP attempts, honors Retry-After, and reports actual error responses. It does not create a message or implement the support router. Keep the raw response in a restricted diagnostic context; do not paste it wholesale into a ticket.

import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen

base = os.environ["INFRAI_API_BASE"].rstrip("/")
message_id = quote(os.environ["SMS_MESSAGE_ID"], safe="")
url = base + "/sms/status/" + message_id
request = Request(
    url,
    method="GET",
    headers={"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]},
)

for attempt in range(3):
    try:
        with urlopen(request, timeout=20) as response:
            observation = json.load(response)
        print(json.dumps(observation))
        break
    except HTTPError as error:
        reason = error.read().decode("utf-8", errors="replace")
        if error.code != 429 or attempt == 2:
            raise RuntimeError(f"HTTP {error.code}: {reason}") from error
        delay = float(2 ** attempt)
        retry_after = error.headers.get("Retry-After")
        if retry_after:
            try:
                delay = max(delay, float(retry_after))
            except ValueError:
                retry_at = parsedate_to_datetime(retry_after)
                remaining = (retry_at - datetime.now(timezone.utc)).total_seconds()
                delay = max(delay, remaining)
        time.sleep(delay)
Enter fullscreen mode Exit fullscreen mode

A delayed code creates a particularly awkward edge case: it can arrive after the user has requested another one. The verification policy must define which challenge remains valid, and the UI must tell the user how to proceed. Support needs the attempt sequence and verification outcome to investigate that case. It does not need to retain either code.

Keep a diagnosis trail, then let detail expire

Retain the minimum evidence that supports a concrete question: which challenge produced the ticket, which destination policy applied, how many sends were authorized, what sender configuration was selected, and what delivery observations were available at the time. Distinguish an observation timestamp from the time the user reports receiving a message. Combining them into one “delivery time” conceals uncertainty precisely where support needs it most.

Set a documented retention period for that restricted diagnostic record according to the support purpose and applicable obligations. Country-level aggregates may answer routing questions without preserving the full phone number in every record. They still need review for re-identification risk and access control. Do not promise that aggregation alone makes authentication data anonymous.

The deliberate deletion is the hard part. Stop keeping OTP values in support evidence, repeated copies of contact-form text, and detailed attempt histories after their justified investigation window. That choice reduces unnecessary sensitive material and limits how much old evidence the system must carry. It also has a cost: a complaint arriving after deletion may be impossible to reconstruct at the individual-attempt level. Keep that limitation visible in the support process. A bounded diagnosis trail is useful only if the team understands both what it can explain and what it has chosen to forget.

Further reading

References for evaluating SMS integrations and the support workflow:

Top comments (0)