A media contact form needs to preserve why a submission reached a particular support queue after its phone number passed an SMS code check, even if the browser retries. Treating “SMS sent” as compliance evidence leaves the important decision unexplained.

Short answer: for phone verification with SMS OTP, accept the code through a server-side operation that checks expiry and attempt limits, consumes the challenge once, and records the routing decision in the same durable transaction. A Node.js contact-form handler can call that operation; the Python example below specifies the storage boundary. Keep delivery receipts and successful verification as separate events.

Evidence needs boundaries.

The useful question is whether a reviewer can reconstruct the transition from an unverified media inquiry to an approved queue assignment without finding a reusable code, an unbounded retry path, or an unexplained second decision. This is an evidence-design problem with an authentication component, and its answer depends more on transaction boundaries than on the messaging interface.

What does an SMS code establish about a phone number?

An SMS challenge can support a claim that someone could receive a code at the challenged destination at that time. It doesn't establish their legal identity, their authority to represent a newsroom, or the truth of their message. NIST's digital identity guidance treats authentication over the public switched telephone network as restricted and calls for consideration of risks such as SIM changes and number porting. That boundary matters when deciding what phone verification may authorize.

For this proposed design, successful verification permits routing a general inquiry into the audience-support queue. Account recovery and sensitive editorial material need their own authorization policies; marking the phone challenge successful must not silently grant those additional permissions.

Consider a test submission: inquiry-042, category subscription_access, destination audience_support. These are illustrative application values, not an observed incident or a standard taxonomy. The category determines the candidate queue through a versioned routing policy; the challenge determines whether that particular submission may proceed. Neither is evidence of the other.

There's an email-shaped trap here, too. DKIM, specified in RFC 6376, associates a signing domain with an email message through a digital signature. A valid signature on an emailed support notification cannot prove that the visitor passed an SMS challenge. Preserve the verification event independently, even if the resulting notification travels through a signed email pipeline.

Make the routing decision durable before dispatch

Start with a submission identifier created by the server. Bind the challenge to that identifier, the phone destination record, and the purpose of the check. Changing the destination must require a fresh challenge; otherwise an accepted code can become evidence for a phone number it never challenged.

The proposed model has a challenge record, a verification outcome, and an outbox entry. The challenge holds an expiry, an attempt counter, and a keyed digest of the code. The outcome holds the submission reference, challenge reference, policy revision, selected queue, and acceptance time. The outbox describes dispatch work that becomes eligible after acceptance. Store raw form content and the phone destination under their own access and retention policies, using references from the evidence record where needed.

A hash deserves scrutiny. A six-digit decimal code has only 1,000,000 possible values, so an unkeyed digest leaves a small search space if challenge records are exposed. A keyed digest, with the key kept separately from that database, changes that particular exposure; it doesn't replace online rate limiting or protect the system if both stores are compromised. NIST requires rate limiting for short authentication secrets. Set the lifetime and retry budget through an explicit policy rather than presenting an arbitrary constant as a standard.

Commit consumption, acceptance, and pending dispatch together.

If acceptance commits first and dispatch is recorded later, a process interruption can leave a verified submission with no durable routing work. If dispatch happens first, a retry can dispatch an inquiry whose authorization never committed. An outbox keeps the pending work alongside the decision; a worker subsequently delivers it, using a stable event identifier so the receiving queue can suppress repeats. This is an application invariant to implement and test, not a claim that a transport guarantees exactly-once delivery.

Durability still has an operational meaning. The transaction guarantee depends on the database configuration and recovery procedure. A consistent application state cannot compensate for an untested backup or a restore that loses the only copy of the evidence.

Put single-use semantics inside the storage operation

The following Python excerpt implements the acceptance boundary for a single SQLite database. Its table names describe a proposed application schema, not a messaging API. Provisioning must create challenges, verification_events, and outbox, with the columns used below; the challenge issuer stores the keyed digest produced by code_mac. Require unique challenge identifiers, one verification event per challenge, and unique outbox event identifiers.

The challenge stores a server-controlled routing policy revision and queue. A browser supplies the submission reference, challenge reference, and candidate code; it must not choose its own accepted queue. This excerpt assumes the endpoint has already bound the caller to that pending submission.

import hashlib import hmac import sqlite3 import time from contextlib import closing def code_mac(key, challenge_id, candidate): message = f"{challenge_id}:{candidate}".encode("utf-8") return hmac.new(key, message, hashlib.sha256).digest() def verify_and_route(db_path, key, submission_id, challenge_id, candidate): with closing(sqlite3.connect(db_path, isolation_level=None)) as db: db.row_factory = sqlite3.Row db.execute("BEGIN IMMEDIATE") try: row = db.execute( "SELECT * FROM challenges " "WHERE id = ? AND submission_id = ?", (challenge_id, submission_id), ).fetchone() now = int(time.time()) if row is None: result = "rejected" elif row["consumed_at"] is not None: result = "already_processed" elif now >= row["expires_at"] or row["attempts_left"] <= 0: result = "rejected" else: db.execute( "UPDATE challenges SET attempts_left = attempts_left - 1 " "WHERE id = ?", (challenge_id,), ) valid_shape = ( len(candidate) == 6 and candidate.isascii() and candidate.isdecimal() ) accepted = valid_shape and hmac.compare_digest( code_mac(key, challenge_id, candidate), row["code_mac"] ) if not accepted: result = "rejected" else: db.execute( "UPDATE challenges SET consumed_at = ? WHERE id = ?", (now, challenge_id), ) db.execute( "INSERT INTO verification_events " "(challenge_id, submission_id, accepted_at, " "policy_revision, queue_name) VALUES (?, ?, ?, ?, ?)", (challenge_id, submission_id, now, row["policy_revision"], row["queue_name"]), ) db.execute( "INSERT INTO outbox " "(event_id, submission_id, queue_name) VALUES (?, ?, ?)", (challenge_id, submission_id, row["queue_name"]), ) result = "accepted" db.execute("COMMIT") return result except Exception: db.execute("ROLLBACK") raise 

The deliberate detail is the rejected-code path: it commits the decremented counter. Raising an exception for every invalid code inside a transaction that rolls back would also restore the attempt budget. That's a concrete way to write a retry limit that never limits retries.

SQLite documents that BEGIN IMMEDIATE starts a write transaction immediately and can fail with SQLITE_BUSY when another writer is active. This example serializes competing writes at a broad boundary; a production implementation must evaluate contention and its own database's locking semantics. A busy database is a storage failure, not an incorrect code. Retry the whole operation under a bounded policy.

The HTTP layer still has work to do: validate types and input sizes, protect the operation against cross-site request forgery where applicable, and apply issuance and verification throttles beyond the per-challenge counter. Generate codes using a cryptographically secure random source. Keep secrets out of logs. The excerpt implements neither SMS delivery nor these endpoint controls, and already_processed reports an existing outcome without authorizing a fresh session. Fresh authentication requires a fresh challenge.

Compare evidence boundaries after defining the invariant

With the state transition defined, the implementation choice becomes easier to inspect. Ask what records each design leaves after an interruption.

Design Useful property Evidence boundary and trade-off
Application-controlled challenge and routing transaction Consumption, acceptance, and pending dispatch can share one commit The application owns secret handling, throttling, concurrency, and retention
External verification service plus local routing ledger The service can own issuance and code validation External acceptance and local commit are separate events; persist correlation identifiers and reconcile ambiguous outcomes
Delivery callback used as the routing gate Delivery events help explain transport behavior Delivery status does not establish successful code entry and cannot support the acceptance claim

An external verification boundary can be reasonable, but the integration must answer a difficult question: if the service accepted the code and the local write didn't complete, how does a retry discover the accepted outcome without inventing another success? The answer depends on documented retrieval, correlation, and idempotency behavior. If that behavior is undocumented, the evidence gap remains unresolved.

Costs follow the boundary too. Evaluate message issuance, abuse controls, retained evidence, reconciliation work, and on-call ownership together. A delivery charge alone says little about whether the team can explain a disputed queue assignment.

Keep policy revisions and identifiers useful for reconstruction. Avoid retaining codes, keyed digests, or raw phone numbers in the general audit stream merely because storage is available. Define access and retention rules for the evidence itself. An immutable record isn't an automatic legal conclusion; compliance adequacy requires review of the applicable obligations and actual controls.

Roll out with interruption tests and a reversible routing switch

Run the proposed routing policy in shadow mode and compare candidate queues with existing decisions. The shadow path must not send extra challenges or dispatch duplicate inquiries. Then enable the acceptance transaction for a bounded slice of submissions, retaining a switch that can pause new verification-gated routing while committed outbox work remains traceable.

Before expanding, test simultaneous submissions of the same valid code, an expired challenge, repeated invalid codes, destination replacement, and an interruption after commit but before the browser receives its response. Each accepted challenge should produce one acceptance event and one logical dispatch, including when transport retries occur.

Rehearse a restore.

Monitor rejected attempts, challenge issuance, oldest pending outbox work, and mismatches between accepted events and queue acknowledgments. Use identifiers for correlation and keep codes out of telemetry. When the acceptance record explains the chosen queue and dispatch can recover from interruption, the media form has an engineering trail that can be reviewed against its compliance requirements.

References

The sources below establish the authentication limits, message-signature boundary, and library behavior used in the design. The queue names and transaction layout are proposed application choices.

Sources