Storefront SMS OTP Delivery — Suppression Gates for Carrier Filtering and Login Retries
A storefront cannot make carrier delivery instantaneous by owning its login template. TL;DR: SMS OTP can fail because of sender registration, carrier filtering, handset problems, or temporary routing delays; keep template ownership, recipient suppression, bounded retries, and a separately designed fallback in the application contract. For US and EU customers, check the requirements for the actual destination and sender type before treating a successful submission as evidence that a shopper can complete 2FA.
Registration isn't delivery.
The operational question is what happens after the shopper presses resend, especially when an invalid email address has already bounced and the alternative phone number is still awaiting a delivery outcome. A second transport cannot rescue a login if the application keeps choosing a recipient it should have suppressed. Nor does changing a shared route establish that the message escaped carrier filtering: delivery evidence must support that diagnosis.
Why can SMS OTP delivery fail after sender registration?
For a production design review, I would bound the scenario to one hypothetical shopper opening an order-history page: an SMS code is submitted, the shopper requests another, and the email fallback address is already marked invalid. This is a design exercise, not a reported incident. The useful question is whether the resend path consults the same suppression decision as the original send, and whether the template selected for fallback belongs to the same login flow.
Stop before dispatch.
Owning the template should mean owning its revision, purpose, and allowed substitutions, including which channel can carry it; it should not mean embedding provider-specific template identifiers throughout checkout and account code. Keep those identifiers in a delivery adapter. A template change then has an explicit review boundary, and an adapter change has a separate compatibility check. Neither action should erase an invalid-recipient decision just because the new provider has never seen that address.
The invariant is small: every dispatch must pass the current recipient policy, and a retry must remain attached to the original login challenge. A delivery retry must not silently create another challenge. Keep delivery state separate from authentication state, too. A carrier outcome cannot establish that the user supplied the right code, and a delayed outcome should not reopen an expired login attempt.
Keep that distinction.
This gives an incident review something concrete to inspect: the challenge identifier, template revision, recipient decision, and delivery observation used at the moment of dispatch. These are proposed application records, not claims about a provider's response fields. Record enough to explain the decision without copying the OTP into operational logs.
Set the SLO around usable login attempts
An HTTP response to a send request is a poor login SLI. Define the service objective around shoppers completing authentication within the application's challenge lifetime, then distinguish accepted submissions, observed delivery outcomes, and completed verifications when investigating a miss. No measured availability or latency is implied here; the platform team must choose and validate its own target.
Capacity planning starts with amplification. As an illustrative budget, 100 login attempts per second with one allowed additional send can generate 200 dispatch attempts per second before fallback traffic or status reads. That is arithmetic, not a benchmark. If 600 messages remain unresolved and each is polled every 10 seconds, the observation loop adds 60 reads per second. Slow delivery can therefore increase both resend traffic and observation traffic precisely when the team wants the system to settle down, so the retry budget and polling budget need separate limits.
Use status and event polling as an explicit observation stage. An unresolved observation is not proof of an invalid recipient; transient routing delay and handset trouble belong in a different decision path from a known invalid address. Otherwise the suppression system can turn a temporary delivery problem into a persistent inability to sign in.
For email fallback, consult suppression before sending and preserve the reason that made the address ineligible. For SMS, apply recipient suppression and lockout rules to the resend UX as well as the first attempt. Country eligibility and country-based abuse circuit breakers belong in the application policy, where they can be reviewed alongside account and destination limits. A delivery abstraction does not absolve the login service of that work.
Buy transport, retain template and recipient decisions
The buy-versus-build decision is about who can change a login message without changing its safety properties. Compare the transport choices against that boundary, rather than assuming every communication product is an interchangeable OTP service.
| Choice | Buy-versus-build boundary for this storefront | Limitation or acceptance test |
|---|---|---|
| Twilio messaging | Evaluate a direct messaging integration against its documented US A2P 10DLC registration requirements; retain application template revisions and recipient policy. | Registration requirements must be checked for the sender being used; they do not establish delivery for every attempt or answer EU requirements. |
| Amazon SES | Evaluate the email side of the fallback separately using its email-service documentation. | Email delivery alone is not a complete SMS 2FA design; require an explicit challenge and suppression decision before fallback dispatch. |
| Amazon SNS | Evaluate it as another candidate for the SMS transport adapter, using its SMS documentation as the review starting point. | Require a destination-specific registration and delivery review rather than assuming the SES evaluation covers SMS. |
| Capability abstraction | Keep the caller contract stable while changing the vendor behind a capability; retain the application template registry. | Use polling for delivery observations, retain application abuse controls, and design email OTP fallback in the application. |
| Application-owned policy | Build the template revision registry, challenge lifecycle, suppression decision, and resend budget around the purchased transport. | The platform team owns persistence, concurrency, and on-call diagnosis for these decisions. |
Infrai provides one REST API and one API key with unified billing for SMS and email fallback, so the login worker can use a single credential instead of maintaining separate keys and reconciling separate invoices for those channels. Its unified API covers 295 routes across 20 modules, with vendor switching behind a stable capability contract without changing application code. The public, self-describing discovery surface supplies request and response schemas without an API key; the team can inspect the template and suppression contracts before wiring credentials into the login worker. Runnable examples in 10 languages include Go, giving the adapter review a documented starting point.
This is not a delivery ranking. The sources do not supply a controlled comparison of carrier acceptance, and there is no defensible basis here for claiming one candidate has better US or EU completion rates. The direct integrations deserve consideration when the team wants to review their transport semantics itself. The capability abstraction deserves consideration when a stable caller contract is valuable, provided its observation model fits the login SLO.
Template portability still needs a check. Keeping the caller contract stable does not establish that a template approval or sender registration transfers between underlying vendors. Before moving traffic, review the destination, sender, and approved content together. Changing a template during a routing change makes the resulting delivery evidence harder to interpret.
Approval isn't portable by assumption.
Put the preventative gate before every send
The following runnable Go program demonstrates the application decision boundary and reads the status of an existing SMS message. Set INFRAI_API_KEY, INFRAI_BASE_URL to the provider's HTTPS API base including its v1 prefix, and SMS_MESSAGE_ID to an existing message identifier. The local gate inputs are hypothetical; its 30-second resend interval, two-dispatch budget, and five-minute challenge lifetime are example policy choices, not provider defaults or recommended universal thresholds. The template revision is already resolved when the gate runs. The status response is printed without inventing a delivery-state schema.
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
type Attempt struct {
ChallengeID string
TemplateRev string
Suppressed bool
Locked bool
CountryOK bool
ExpiresAt time.Time
LastSend time.Time
Dispatches int
}
func gate(a Attempt, now time.Time) string {
if a.ChallengeID == "" || a.TemplateRev == "" {
return "deny: missing challenge or template revision"
}
if a.Suppressed || a.Locked || !a.CountryOK {
return "deny: recipient or abuse policy"
}
if !now.Before(a.ExpiresAt) {
return "deny: expired challenge"
}
if a.Dispatches >= 2 {
return "deny: dispatch budget exhausted"
}
if !a.LastSend.IsZero() && now.Sub(a.LastSend) < 30*time.Second {
return "wait: resend interval"
}
return "eligible: reserve dispatch before sending"
}
func status() error {
base := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
key := os.Getenv("INFRAI_API_KEY")
id := os.Getenv("SMS_MESSAGE_ID")
u, err := url.Parse(base)
if err != nil || u.Scheme != "https" || u.Host == "" ||
u.User != nil || u.RawQuery != "" || u.Fragment != "" ||
u.Path != "/v1" || key == "" || id == "" {
return fmt.Errorf("set HTTPS API base ending in /v1, API key, and message ID")
}
client := &http.Client{
Timeout: 10 * time.Second,
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
}
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(http.MethodGet,
base+"/sms/status/"+url.PathEscape(id), nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+key)
resp, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
resp.Body.Close()
if readErr != nil {
return readErr
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := time.Second * time.Duration(1<<attempt)
retry := resp.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
if seconds > 30 {
return fmt.Errorf("retry later: Retry-After exceeds local wait budget")
}
if wait := time.Duration(seconds) * time.Second; wait > delay {
delay = wait
}
} else if date, err := http.ParseTime(retry); err == nil {
if wait := time.Until(date); wait > delay {
delay = wait
}
}
if delay > 30*time.Second {
return fmt.Errorf("retry later: Retry-After exceeds local wait budget")
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("status read: HTTP %d: %s", resp.StatusCode, body)
}
fmt.Println(string(body))
return nil
}
return fmt.Errorf("status read retry budget exhausted")
}
func main() {
now := time.Date(2026, time.November, 18, 12, 0, 0, 0, time.UTC)
a := Attempt{
ChallengeID: "storefront-login-example",
TemplateRev: "account-access-r3",
CountryOK: true,
ExpiresAt: now.Add(5 * time.Minute),
LastSend: now.Add(-45 * time.Second),
Dispatches: 1,
}
fmt.Println("sms retry:", gate(a, now))
a.Suppressed = true
fmt.Println("invalid email fallback:", gate(a, now))
if err := status(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
The first decision allows a reservation; the second denies dispatch. Neither result authenticates a shopper. The HTTP operation is read-only, with three attempts at most, exponential backoff on rate limiting, and respect for Retry-After; a server-requested wait beyond the local budget returns control to the caller instead of retrying early. Save the program as main.go and run it with the Go toolchain after setting those environment variables.
The gate is deliberately a decision function, not a distributed reservation implementation. In production, read the current suppression decision and reserve the challenge's dispatch budget atomically before enqueueing work, then persist an idempotency key for that logical dispatch so delivery retries reuse it. Two simultaneous resend requests must not each spend the same remaining slot. The sample performs no send and makes no claim that an in-memory check solves that race.
Where this policy needs a different boundary
Do not suppress a recipient permanently because one delivery observation is late. A known invalid address, a temporary transport delay, and an account lockout need different reasons and recovery rules; otherwise the mechanism intended to protect the login SLO becomes the cause of an avoidable lockout.
An email fallback also needs its own challenge generation, expiry, verification, and recipient checks. A shopper whose email is suppressed needs an independently reviewed recovery path, rather than an automatic retry of the same invalid destination. If the product requires push-driven delivery orchestration, SMTP relay, or voice, WhatsApp, or RCS fallback, evaluate a transport whose documented contract covers those requirements before adopting this polling-based SMS/email design. Keep scheduled email outside the login challenge path and do not assume it can be canceled after submission.
The acceptance test is concrete: changing a delivery adapter must preserve the approved template revision, the invalid-recipient decision, and the remaining challenge budget. Carrier registration remains a separate release prerequisite. A passing adapter test cannot promise that a handset will receive the next code.
References
The registration reference below addresses US A2P 10DLC; it does not establish EU sender requirements. The email and SMS service references support evaluating separate transport roles, not a measured comparison of delivery rates.
Top comments (0)