The integration shortcut is to let a successful phone login stand in for evidence that a logistics compliance notice reached its recipient. Resist that shortcut: use one correlation model for the transaction alert, verification challenge, and notice, but give each its own state and evidence. TL;DR: a Next.js SMS OTP resend button should display a backend deadline; the backend should enforce resend eligibility atomically, while a separate notice record preserves what was sent and what each receipt actually establishes. This keeps integration work bounded without treating authentication as delivery proof.
Consider a proposed workflow in which a carrier must notify a consignee about a shipment payment hold, and the consignee signs in with a phone code before reviewing the notice. The payment event explains why the notice exists. The code controls access. Neither event, by itself, proves that the consignee received or acknowledged the notice. For a backend designed around ledger reconciliation, collapsing those events would erase precisely the distinctions an auditor would need to inspect.
How should phone login with SMS OTP relate to notice evidence?
Start by naming the claims the application intends to make. In this design, a successful challenge records that a code was accepted for a particular authentication purpose under a particular verification policy. The logistics notice record describes different things: a shipment reference, a notice revision, the destination used at dispatch, and the subsequent evidence. Treat a transport receipt as a statement from that transport, with its original meaning preserved, rather than silently translating it into a stronger assertion about the person reading the notice.
Keep claims narrow.
This distinction matters across channels. RFC 6376 defines DKIM as a way for a signing domain to claim responsibility for a message; a valid signature is not a recipient acknowledgment. Apple's Mail Privacy Protection documentation describes privacy measures that prevent senders from learning whether a message was opened. Accordingly, an email open signal should not become the decisive compliance event in this workflow. Those sources support limits on particular evidence types; they do not establish which evidence satisfies a logistics obligation in either the US or the EU.
Make that legal boundary explicit in the requirements. Ask the responsible compliance team to identify the applicable notice obligation, acceptable delivery or acknowledgment evidence, retention period, and permitted destinations before assigning a terminal state such as “requirement satisfied.” Jurisdiction labels alone cannot answer those questions. A transaction alert, an authentication message, and a statutory notice may need different treatment even when they concern the same shipment.
Derive the retry contract from the evidence model
In this worked example, shipment SHP-204 has notice revision 3 and a proposed retry interval of 45 seconds. These are illustrative application values, not measurements or prescribed security thresholds.
Give the notice a stable identifier independent of the current OTP challenge, and link both records to the initiating payment event. A contact change should create an explicit routing decision in the audit trail; do not let an edit to the account's current phone number rewrite the destination recorded for an earlier dispatch.
The resend response should expose a server-calculated eligibility deadline and a server timestamp. In the Next.js client, derive the displayed countdown from that deadline, refresh state after a suspended tab resumes, and reconcile again after a rejected request. Disabling a button is a presentation choice. Every resend request still needs an authoritative backend decision, including requests from two browser tabs that both display zero.
For this design, make that decision inside a transaction that locks the challenge row or performs an equivalent conditional update. Check the challenge purpose, expiry, retry policy, and resend deadline together, then advance the eligible time and insert one dispatch intent before committing. An outbox worker can process that intent afterward. Keep the provider call outside the database transaction so the application does not hold a database lock across an external network operation.
The atomicity requirement applies to local state.
It does not make a database commit and an external send one indivisible action. If a worker times out after the transport accepted a message, its next step must account for an uncertain outcome. Reuse a stable dispatch identifier when the transport contract supports deduplication, preserve the attempt history, and reconcile available receipts before deciding how to retry. Do not rename uncertainty as failure merely to simplify a status column. The trade-off is additional reconciliation work in exchange for an honest record of what the application knows: a worker that has lost its response cannot infer the external outcome from the timeout alone, and a replacement worker needs persisted identifiers to investigate the same logical attempt.
The following Go example defines the application boundary rather than pretending to implement a transport. Its store contract deliberately places the lock, eligibility check, idempotency lookup, and outbox insert in one operation; a production implementation must supply those semantics.
package notices import ( "context" "errors" "time" ) type ResendRequest struct { ChallengeID string IdempotencyKey string } type ResendDecision struct { DispatchID string EligibleAt time.Time ServerTime time.Time Accepted bool } type ResendStore interface { // Atomically enforce eligibility and persist the decision and outbox intent. // Scope keys to the authenticated principal and operation. // Replay matching requests; reject key reuse with different input. DecideAndEnqueue(context.Context, ResendRequest) (ResendDecision, error) } func RequestResend( ctx context.Context, store ResendStore, req ResendRequest, ) (ResendDecision, error) { if req.ChallengeID == "" || req.IdempotencyKey == "" { return ResendDecision{}, errors.New("missing resend identifiers") } return store.DecideAndEnqueue(ctx, req) } Authenticate and authorize the request before invoking this function. Do not use possession of a challenge identifier as authorization. The interface also leaves abuse limits and code verification policy to the implementation: idempotency prevents a replayed request from creating another dispatch intent, but an attacker can submit distinct keys. A separate rate policy must govern those requests.
Reconcile notice evidence without storing authentication secrets
For the proposed audit record, retain the notice identifier and revision, the initiating event reference, the destination snapshot under an appropriate access policy, the dispatch identifier, and the timestamps that distinguish local creation from external observation. Store the original receipt classification alongside the application's normalized state. This lets a reviewer trace a conclusion back to the evidence instead of trusting a status word that may have changed meaning during an integration migration.
Do not log OTP values.
The audit objective is to explain the verification decision, not to retain a reusable credential. Record the challenge reference, the policy decision, and the resulting relationship to the authenticated session. Similarly, protect destination data and notice contents rather than copying them indiscriminately into every operational log. Define access and retention with the responsible team; neither DKIM nor a privacy feature document supplies a universal retention schedule for this application.
An exactly-once mindset is useful when it means one durable business decision for a defined logical operation. It becomes misleading when it promises exactly one physical SMS across arbitrary network failures. Specify which uniqueness the database enforces, which deduplication the external contract offers, and which ambiguous outcomes require reconciliation. Those are separate integration obligations.
Exercise them before rollout. In a concurrency test, submit two eligible resend requests against the same challenge and check that only one new dispatch intent is committed. Replay an accepted idempotency key after a simulated lost response and verify that the original dispatch identifier returns. Then interrupt a worker after external acceptance but before its local acknowledgment: the expected result is a visible uncertain attempt awaiting reconciliation, with no invented assertion that delivery failed. These are proposed acceptance tests, not claims about observed production behavior.
Receipt processing deserves its own tests. Submit duplicates and reverse their arrival order; require the handler to authenticate incoming evidence according to the integration contract, retain the event identity, and avoid double-applying it. A late transport event should not overwrite a separately recorded recipient acknowledgment. Monitor unresolved attempts and receipt-processing lag so the team can see where the evidentiary chain stops.
Compare integration effort after defining the claims
Only now is a comparison useful. Count the state transitions, reconciliation jobs, and support investigations that each approach adds. The fewest initial calls can still leave the application with the most difficult evidence reconstruction.
| Approach | Initial integration work | Evidence and operational trade-off |
|---|---|---|
| Client countdown with a direct send handler | Small UI and handler surface | Add server eligibility enforcement and durable dispatch state before using it for this workflow |
| Separate verification and notice adapters with shared identifiers | More explicit mapping between records | Each claim can be reconciled against its own events and policy |
| Shared orchestration with channel adapters | Central state model plus adapter contracts | Reduces duplicated application policy, while requiring careful mapping of receipt meanings |
These are architectural alternatives.
For a team already maintaining a transactional event store and worker, extending that existing mechanism may reduce new concepts; for a team without those components, the same design creates deployment, recovery, and monitoring work that must be included in the estimate. Compare the actual ownership burden. A compact wrapper around a send call does not eliminate that burden.
Include retry volume, retained evidence, callback processing, and support access in the operating-cost discussion. Avoid optimizing the message count before deciding whether the resulting record can explain what happened. An inexpensive dispatch that cannot be reconciled is a poor unit of success for a compliance notice.
Roll out by proving the evidence chain
Begin with a small, explicitly approved class of notices, and record the required evidence for that class before enabling automated closure. In staging, trace SHP-204 from the payment event through notice revision 3, challenge verification, dispatch attempts, and the receipt used for the final decision. Rehearse lost responses and repeated callbacks against that same chain.
During migration, preserve historical meanings. Version the receipt mapping, keep earlier routing snapshots intact, and expose unresolved attempts to the operations team instead of backfilling them as delivered. Expand coverage when the team can reconstruct a notice decision from retained evidence and explain each retry. The resend countdown then has a precise role: it communicates eligibility while the backend preserves the decisions that matter.
References
The references below support the limits of domain signatures and email-open evidence. The application identifiers, resend interval, state model, and acceptance tests above are proposed design choices.
Sources
- RFC 6376, DomainKeys Identified Mail (DKIM): https://datatracker.ietf.org/doc/html/rfc6376
- Apple, Use Mail Privacy Protection on iPhone: https://support.apple.com/guide/iphone/use-mail-privacy-protection-iphf084865c7/ios


