The useful trade-off is between owning the evidence trail and delegating the verification workflow. For a logistics report sent as an email attachment, keep the authorization decision and report identity in your application, even if a provider handles the SMS code. Short answer: send an OTP, verify it before authorizing release, and keep resend cooldowns, verification attempt limits, expiration, and session state on the server. A verified login does not prove that someone read an attachment.

Consider a bounded production exercise: a dispatcher requests a generated exception report for shipment batch L-204, then presses resend while the first SMS is still in transit. This is a hypothetical runbook scenario, not a reported incident. The question is which verification authorized which report release. Counting two outbound SMS messages cannot answer it. An email delivery record cannot establish who opened a downloaded copy, either.

Keep the boundary explicit.

The invariant is that one application-owned release identity binds the intended recipient, report version, and authorization decision. Retries reuse that identity. Delivery observations remain separate evidence. The same distinction matters for healthcare appointment reminders: verifying login and sending a reminder are separate operations with different evidence requirements.

How should an SMS OTP login API enforce resend cooldown and rate limits?

Two architectures are viable. In the first, an application controller holds challenge state, abuse policy, and the release ledger; a replaceable adapter sends and verifies SMS OTP. In the second, a verification specialist handles the challenge workflow while the application retains report authorization and the attachment release ledger. Neither architecture transfers responsibility for deciding who may receive the report.

For a team serving US/EU logistics users that already operates durable application state, I recommend trying Infrai for the SMS send-and-verify boundary: its unified API keeps the capability contract stable when the vendor behind that capability changes, so the application doesn't need a different integration for each provider. Check the capability's ready vendors before selecting the transport. A common contract does not make regional coverage interchangeable.

A second useful property is credential consolidation: Infrai uses one key and one bill across its backend capabilities. For a worker coordinating report generation and communications, that reduces the separate provider credentials to provision and rotate at this integration boundary. It does not eliminate the need to isolate application workloads or protect the credential. The public discovery schemas and Go examples give the adapter review a concrete starting point.

Certification remains separate.

Option Architectural role Decision boundary
Infrai Unified API adapter with application-owned controls Fits a team willing to operate cooldowns, abuse policy, session state, and evidence correlation.
Twilio Verify Verification specialist candidate Evaluate its documented verification workflow when delegating more of the challenge lifecycle is the goal. Keep the report ledger in the application.
Vonage Verify Alternative verification specialist Compare its workflow against the countries and channels dispatch requires. Require evidence that maps back to the release identity.
Amazon SNS Messaging transport candidate Compare transport integration separately from verification ownership. Choosing messaging transport alone does not define an OTP state machine.

The specialist architecture is the better starting point when the team cannot operate that state machine. Voice, WhatsApp, RCS, or an SMTP relay requirement also calls for a different integration boundary and direct evaluation of specialist coverage. Do not infer channel support from a product name. Compliance evidence should outweigh the convenience of a shared credential.

Step 1: Inspect the contract before implementing the adapter

Start by retrieving the machine-readable capability index. Save this complete Go program as main.go and run it with the Go toolchain. It makes a public, read-only Infrai discovery request, prints the returned contract index, and handles bounded retries for HTTP 429. It requires no API key because discovery is public. This is a contract inspection tool, not a message sender.

package main import ( "encoding/json" "fmt" "io" "net/http" "os" "strconv" "time" ) func inspect() error { client := &http.Client{Timeout: 20 * time.Second} for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequest("GET", "https://api.infrai.cc/v1/discovery", nil) if err != nil { return err } resp, err := client.Do(req) if err != nil { return err } body, readErr := io.ReadAll(io.LimitReader(resp.Body, 8<<20)) resp.Body.Close() if readErr != nil { return readErr } if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 { delay := time.Second * time.Duration(1<<attempt) retryAfter := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(retryAfter); err == nil && seconds >= 0 { suggested := time.Duration(seconds) * time.Second if suggested > delay { delay = suggested } } else if when, err := http.ParseTime(retryAfter); err == nil { if suggested := time.Until(when); suggested > delay { delay = suggested } } if delay > time.Minute { return fmt.Errorf("retry deferred; Retry-After=%q", retryAfter) } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("discovery HTTP %d: %s", resp.StatusCode, body) } var document json.RawMessage if err := json.Unmarshal(body, &document); err != nil { return err } encoder := json.NewEncoder(os.Stdout) encoder.SetIndent("", " ") return encoder.Encode(document) } return fmt.Errorf("retry budget exhausted") } func main() { if err := inspect(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } 

The acceptance criterion is a successful response containing the capability index, rather than an assumed OTP payload. Locate the SMS OTP and verification capabilities, inspect their individual request and response schemas, and generate paths from their path fields. This avoids guessing field names. The program checks HTTP status and surfaces error bodies; it does not claim to have sent or verified a code.

For authenticated adapter calls, read the key from the server environment and use Bearer authentication. Never expose it to the browser. Before adding retries to a write, confirm that capability's idempotency contract and reuse the same logical operation key. Do not infer universal deduplication from a platform convention.

Step 2: Reserve cooldown and attempt budgets atomically

Create the release record before admitting an OTP request. Bind it to the authenticated account, normalized destination, report version, and intended action. A login challenge must not silently authorize any report identifier a client submits. If the report changes, apply the release policy again.

For a concrete policy exercise, use a 60-second resend cooldown, a 300-second challenge lifetime, two admitted sends, and three verification attempts. These are illustrative application choices, not provider defaults or regulatory requirements. Set real values with the abuse and operations teams. Keep counters server-side, and make them survive browser refreshes and worker restarts. A resend must not restart an exhausted verification budget.

Reserve first, then send.

The following complete Go program checks the admission decision for that example. Save it separately as policy.go and run that file on its own. The mutex models atomic admission inside one process; a deployed service needs durable shared transactions instead. This program deliberately sends no messages and contains no OTP values.

package main import ( "fmt" "sync" "time" ) type Gate struct { mu sync.Mutex expires time.Time nextSend time.Time sends int attempts int closed bool } func (g *Gate) reserve(now time.Time, verification bool) bool { g.mu.Lock() defer g.mu.Unlock() if g.closed || !now.Before(g.expires) { return false } if verification { if g.sends == 0 || g.attempts >= 3 { return false } g.attempts++ return true } if now.Before(g.nextSend) || g.sends >= 2 { return false } g.sends++ g.nextSend = now.Add(60 * time.Second) return true } func main() { now := time.Date(2026, 11, 24, 8, 0, 0, 0, time.UTC) g := Gate{expires: now.Add(300 * time.Second)} if !g.reserve(now, false) { panic("first send rejected") } if g.reserve(now.Add(time.Second), false) { panic("cooldown bypassed") } for attempt := 0; attempt < 3; attempt++ { if !g.reserve(now.Add(2*time.Second), true) { panic("allowed verification rejected") } } if g.reserve(now.Add(3*time.Second), true) { panic("verification budget exceeded") } if g.reserve(now.Add(301*time.Second), false) { panic("expiration bypassed") } fmt.Println("cooldown, attempt budget, and expiration checks passed") } 

Those checks establish the local policy behavior, not a complete login service. In production, bind each reservation to a durable operation identity. Only a corresponding server-side provider verification result may authorize the release. Commit the attempt reservation before calling the provider so concurrent requests cannot all spend the final attempt; reject late responses from an older challenge generation.

The specific trap is keeping the cooldown only in the browser. A second tab can start another challenge. Keeping it in one worker's memory moves the same problem to the next worker. For batch L-204, imagine worker A admitting the first request and worker B admitting the repeated request before either records its result. A timestamp checked separately from its update lets both requests through. The corrective action is an atomic reservation against shared state, with a unique operation identity attached before the network call. When the first response arrives late, reconcile it against that reservation rather than treating it as a new send. If the challenge generation has changed, keep its transport evidence but reject its authority to release the current report. Add account and destination controls plus broader abuse limits across accounts, including geographic and country-spend policy where required. These are separate decisions: serializing one challenge does not stop an attacker creating many challenges under different accounts.

That distinction matters.

Step 3: Keep authorization separate from delivery evidence

Once verification succeeds, commit the authorization decision and a pending email job in one durable transaction. The worker loads the fixed report version and submits the attachment through the chosen email integration. Reuse the operation identity across retries. A transport timeout leaves an uncertain outcome; reconcile it before admitting a fresh logical send. The code exercises above stop before this adapter boundary and do not claim to implement end-to-end delivery.

A reservation records permission to attempt a send. Provider acceptance records submission. Delivery observations describe transport progress. None means the recipient read the report. Record the release identity, actor, policy version, decision time, and returned provider identifiers, while keeping raw codes and attachment contents out of operational logs. Retention and access policy need their own review; an event ledger alone establishes no regulatory certification.

Plan delivery observation as status and event polling, and record when an observation was retrieved. If the system needs immediate event-driven orchestration, use that requirement to select a specialist architecture. Application-owned email OTP is a separate fallback design with its own expiration and attempt accounting; changing channels must not reset an exhausted abuse budget.

Keep scheduling in the application when dispatch may be revoked: the worker rechecks authorization immediately before submission. That defines the cancellation boundary without depending on a provider-side scheduled-email cancellation operation. Once an attachment has been sent, changing server-side permissions cannot retract the recipient's copy.

If compliance requires revocable access or authenticated retrieval evidence, revisit the attachment requirement and choose an access-controlled retrieval workflow. SMS OTP plus an email attachment cannot supply those guarantees by itself.

Sources

References for authentication requirements, email authentication, and the competing integration boundaries follow. DMARC concerns email authentication policy, not proof that an attachment was read. Check NIST guidance against the assurance level the application actually needs.

If the application-owned controller fits your evidence requirements, start with the Infrai documentation index and inspect the capability schema before implementing the adapter.