The bill for sending signup OTPs via SMS and email in healthtech has several parts: the channel attempts, retries, event collection, and the storage and access controls around the evidence left afterward. For an illustrative workload of 100,000 signups a day, two channel attempts per signup, three retained events per attempt, and 700 bytes per event, keeping those events for 30 days means 12.6 GB of logical event data before indexes, replicas, or backups. Those are planning inputs, not a provider measurement or a legal retention requirement. Within that storage calculation, repeated event payloads dominate.
Short answer: for OTPs sent through both SMS and email, generate one challenge, keep its verifier in an expiring secure store, dispatch the two messages concurrently, and let either channel lead to the same single-use verification decision. In a Node.js service, the concurrency belongs in application logic; the compliance evidence belongs in a separately defined retention policy. A signup link should open the challenge flow, while successful code verification records the account decision.
Sending a code to two destinations does not establish two independent factors. Nor does a delivery receipt establish that the intended person completed signup. For this healthtech workflow, the useful question is which evidence supports each claim, how long it remains necessary, and whether changing the delivery supplier preserves that meaning.
What evidence matters when sending OTPs via SMS and email?
Start with three lifetimes: the challenge secret, the delivery evidence, and the verification outcome. They answer different questions. A live challenge answers whether an entered code can still be accepted; a delivery event describes a channel attempt; an outcome records what the application decided. Keeping all three for the longest period creates a larger sensitive dataset without making the weakest evidence stronger.
Receipts aren't proof.
For a proposed account record such as signup_case_248, assign an opaque challenge identifier and distinct attempt identifiers for email and SMS. These are application-owned identifiers, not assertions about a provider's request fields. Keep phone numbers, email addresses, and the link token out of general diagnostic event bodies; use a controlled association when an authorized investigation needs to resolve an attempt back to a destination. In particular, a signed link or an OTP copied into an audit record becomes another place where a usable credential can survive its intended lifecycle.
A reasonable design distinguishes request accepted, delivery reported, and challenge redeemed. Do not collapse them into a single success flag, even if a dashboard would look cleaner. Each transition needs its own timestamp and source, and an event collected later needs both its source time, when available, and its collection time so an investigator can distinguish a delivery delay from a collection delay. These are proposed evidence requirements; they are not a claim that every provider supplies every timestamp.
For a signup link delivered by email, the page can ask for the same code also sent by SMS. That keeps the concrete job visible: establish control of a signup destination through a short-lived challenge, then record the result. It does not make an email address a patient identity, and it does not by itself satisfy a jurisdiction's health data obligations.
Reduce the retained payload before debating the retention period
The dominant term in the opening estimate is event count multiplied by retained payload size and retention days. Changing an SMS supplier does not remove that multiplication. A better first experiment is to define the smallest evidence record that still answers the investigation questions, then separately authorize its retention period.
Under a second illustrative policy, keeping 200 bytes per normalized event for seven days produces 0.84 GB of logical data at the same activity level. This changes both payload size and duration, so it is a scenario comparison, not a measured compression result. It says nothing about the relative size of the delivery bill, which requires actual channel charges and retry counts.
The following Python example makes that planning arithmetic reproducible. It deliberately performs no message sends and makes no assumptions about provider payload schemas. Although the application in question uses Node.js, this small calculation is independent of the delivery runtime.
from dataclasses import dataclass
@dataclass(frozen=True)
class EvidencePolicy:
bytes_per_event: int
days: int
def logical_bytes(signups_per_day: int, policy: EvidencePolicy) -> int:
attempts_per_signup = 2
retained_events_per_attempt = 3
return (
signups_per_day
* attempts_per_signup
* retained_events_per_attempt
* policy.bytes_per_event
* policy.days
)
policies = {
"fuller_event_history": EvidencePolicy(700, 30),
"short_normalized_history": EvidencePolicy(200, 7),
}
for name, policy in policies.items():
total = logical_bytes(100_000, policy)
print(f"{name}: {total / 1_000_000_000:.2f} GB logical")
The arithmetic is easy. Choosing the fields is harder, because the record must retain enough provenance to explain a decision without quietly becoming a second message archive. A candidate normalized record might contain an opaque attempt identifier, channel, source identifier, collection timestamp, and normalized state. Whether that fits the illustrative 200-byte budget depends on its actual encoding. Measure the serialized record before making a capacity commitment.
Count the copies.
A storage architect should also ask what deletion means. Removing a primary record does not establish that replicas, backups, exports, and incident attachments have reached their own expiry boundaries. The retention policy needs to name those copies and their owners. Otherwise, the short retention period exists only in the application table.
Keep the challenge contract stable across delivery suppliers
Put a delivery adapter behind an application-owned contract that accepts a challenge reference and returns a channel attempt result. The verification decision stays in the application, so replacing the supplier behind a delivery capability can leave the signup code and challenge lifecycle unchanged. Infrai offers one REST API with one key for email and SMS; its capability interface can retain the contract while the underlying vendor changes, and per-call cost, vendor, latency, and request identifiers give the workflow useful reconciliation evidence. This does not establish jurisdictional suitability or a compliance certification.
The choices below are real alternatives, but the table distinguishes the role to evaluate from evidence that must be obtained before procurement. A product category is not an assurance report.
| Option | Role to evaluate for this workflow | Boundary to examine before choosing |
|---|---|---|
| Twilio Verify | A verification service as the owner of the challenge workflow | Determine which challenge events, retention controls, and channel choices the selected configuration exposes; compare those with the application's evidence requirements. |
| Amazon SNS | SMS delivery as a messaging component alongside an application-owned challenge | Establish the separate email path and the evidence joins between both channel attempts and the single verification decision. |
| SendGrid | Email delivery for the signup link and code | Pair it with an SMS option, and inspect how email events can be associated with the same challenge without retaining credential-bearing message content. |
These options are not interchangeable units. A verification service may reduce the challenge machinery the application operates, while a messaging component leaves that ownership with the application; that distinction matters more here than having similar send buttons. The table is an evaluation framework, not a claim that every listed product satisfies the same contract or that any supplier has passed a healthtech compliance review.
For a team that already owns its verifier and evidence store, a capability adapter is a plausible fit. For a team seeking a managed verification lifecycle, evaluate that lifecycle explicitly. In either case, request the applicable contractual and technical evidence for data processing, retention, access, and regional operation before approving the signup workflow. Provider substitution preserves an application interface only to the extent that the adapter enforces its semantics; it never transfers an approval automatically.
The trade-off is ownership: a generic delivery API is not suitable when the requirement is a supplier-managed verification lifecycle. Evaluate Twilio Verify for that requirement. For a separate email delivery component, evaluate SendGrid; neither choice removes the need to examine the applicable retention and compliance evidence.
Concurrent sends still require one redemption boundary
The Node.js implementation should generate the OTP once, store a protected verifier in a secure store such as Redis with an expiration, and launch email and SMS delivery concurrently while retaining each result separately. Do not let one rejected send erase the other channel's result. The email message can contain the signup verification link and application-generated code; the receiving page submits the code to the application's verifier. Because an email delivery capability does not imply a managed email OTP lifecycle, generation, expiration, and acceptance remain explicit application responsibilities.
One challenge. Two attempts.
The Python transport below demonstrates the email adapter's retry boundary without inventing a message schema. Supply COMM_API_ORIGIN as the provider's HTTPS origin, INFRAI_API_KEY as the credential, and COMM_ATTEMPT_ID as a persisted identifier for this particular email attempt. Feed a complete email request JSON document, validated against the public discovery schema, through standard input. The signup service must supply the actual recipient, template, link, and code using that schema; this transport does not construct them. Reusing the attempt identifier is appropriate only for retrying the same message. The SMS adapter is a separate concurrent operation.
import json
import os
import sys
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import urlsplit
from urllib.request import Request, urlopen
origin = os.environ["COMM_API_ORIGIN"].rstrip("/")
parsed = urlsplit(origin)
if parsed.scheme != "https" or not parsed.netloc or parsed.path:
raise ValueError("COMM_API_ORIGIN must be an HTTPS origin")
payload = json.load(sys.stdin)
if not isinstance(payload, dict):
raise ValueError("Supply a schema-validated email request object")
encoded = json.dumps(payload).encode("utf-8")
attempt_id = os.environ["COMM_ATTEMPT_ID"]
for attempt in range(4):
request = Request(
origin + "/v1/email/send",
data=encoded,
method="POST",
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": attempt_id,
},
)
try:
with urlopen(request, timeout=20) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected status: {response.status}")
print(f"Email request accepted: {response.status}")
break
except HTTPError as error:
reason = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"Email request failed: {error.code}: {reason}") from error
delay = float(2 ** attempt)
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
minimum = float(retry_after)
except ValueError:
deadline = parsedate_to_datetime(retry_after)
minimum = (deadline - datetime.now(timezone.utc)).total_seconds()
delay = max(delay, minimum)
time.sleep(delay)
Acceptance is not delivery.
The dangerous failure mode is double redemption: two requests can both observe an unused challenge if verification and consumption are separate operations. Acceptance must atomically check the verifier, expiry, remaining attempts, and unused state, then consume the challenge and record the outcome through an application-defined consistency boundary. A comparison followed by an unrelated delete leaves a race. If audit persistence is separate, define how an accepted outcome is durably recorded and recovered rather than assuming two stores commit together.
Transport retries introduce a different problem. A timeout leaves the caller uncertain whether the supplier accepted the send. Preserve a stable application attempt identity across retries, use documented idempotency support where available, and apply bounded backoff that honors rate-limit instructions. Verify the chosen operation's contract before treating a retry as safe. A newly generated challenge for every retry can make the SMS and email disagree about which code is valid.
Event collection is another boundary. With a pull-based event interface, polling cadence and collector recovery affect when evidence becomes visible. Keep collection lag distinct from delivery lag, and make ingestion tolerant of repeated observations. A callback-shaped internal adapter cannot manufacture a supplier event push guarantee. For this workflow, a slow evidence collector should not cause a successfully redeemed challenge to be issued again.
Abuse controls also belong in the decision: bound resend attempts and verification guesses, and define destination and geographic restrictions in the application policy. A shared delivery interface is not evidence that country-specific abuse controls or regional approvals have been supplied. An available route is insufficient grounds for a domestic compliance claim.
The choice is operationally concrete: accepting either channel improves the chance that a user can complete signup, but assurance now depends on the security of either accepted destination. If the product actually requires two independent factors, do not rename this either-channel flow to imply it has achieved that requirement.
Stop keeping secrets when their decision window closes
Choose the challenge expiry from the product's threat model and usability requirements. After expiry or successful redemption, remove the usable challenge material according to the defined lifecycle. Keep a minimal outcome record only for an approved purpose and duration; a healthtech label alone supplies neither a retention schedule nor permission to retain message bodies.
The deliberate sacrifice in the shorter evidence policy is diagnostic depth. Once raw event payloads are deleted, an investigation may establish that an attempt was recorded and the challenge was consumed without reconstructing every supplier-specific detail. Once message content and usable link tokens are gone, support cannot replay the original credential. Recovery must issue a fresh challenge under the same controls. That is the cost of keeping less.
Before adopting that policy, have the workflow owner decide which disputes require raw delivery evidence and which can be resolved from normalized records, then test recovery and deletion against those decisions. Preserve enough provenance to defend the account decision. Stop keeping credentials as a substitute for evidence.
Further reading
References for comparing the service roles and reviewing template behavior; these links do not establish a healthtech compliance approval or a retention schedule.
- Twilio Verify documentation: https://www.twilio.com/docs/verify
- Amazon SNS documentation: https://docs.aws.amazon.com/sns/latest/dg/welcome.html
- SendGrid documentation: https://www.twilio.com/docs/sendgrid
- Mustache template syntax manual: https://mustache.github.io/mustache.5.html