A gaming account's password-reset code can expire before the team has enough evidence to explain what happened. For a US/EU SaaS login flow, that changes the selection criterion: choose a channel and an evidence path together. Short answer: managed SMS OTP is the straightforward primary verification path in this comparison; email fallback requires an application-owned code lifecycle. Neither a successful send request nor an email open should authorize a reset.
The evaluation constraint is explicit: a reviewer must be able to distinguish a request being accepted, a delivery event being observed, and a code being verified before its deadline. This note proposes that acceptance test; it does not report a production experiment or a compliance certification. For this gaming example, use a hypothetical 180-second expiry, with the server's verification decision as the authority.
Keep verification deterministic. A RAG assistant might help support staff find the relevant evidence later, but an agent should never decide whether the reset credential is valid.
How should SMS OTP and email fallback support SaaS login evidence?
The tempting notebook implementation sends a message, records a success flag, and lets a timer trigger email fallback. That flag compresses several different events into one. If the player asks support why the code arrived too late, the record cannot distinguish a slow delivery from a late verification attempt. Adding another channel without separating those events makes the evidence harder to interpret.
Acceptance isn't delivery.
Instead, assign an opaque reset-attempt identifier before dispatch. Keep the account association in restricted application storage, and record the selected channel, request outcome, application deadline, observed delivery state, and final verification decision against that identifier. These are proposed application records, not provider response-field names. Store observation time separately from any event time that the provider actually supplies. A poll performed after expiration cannot establish when an earlier event became visible to the application.
For this design, a replacement challenge invalidates the previous challenge across channels. That is a deliberate trade-off: it prevents two concurrent credentials from authorizing the same reset, but it can frustrate a player who enters the earlier code. Make the user-facing explanation clear and test the replacement sequence. The deadline belongs to the reset attempt's policy; switching to email must not silently extend it.
This is where the compliance-evidence axis becomes useful. Ask whether the record reconstructs the authorization decision, who can access it, and how long it is retained. An API inventory alone does not establish US or EU compliance, a retention policy, or an acceptable regional processing arrangement.
Compare responsibility before choosing the channel
The useful comparison is about which work remains in the application. Three real alternatives deserve separate consideration, because a messaging provider, an email service, and an observability service occupy different parts of this decision.
| Option | Role in the proposed comparison | Decision boundary |
|---|---|---|
| Twilio Verify | Candidate for the managed verification path | Review its verification contract and evidence against the same expiry and resend tests; a separate telemetry integration needs its own correlation mapping. |
| Amazon SES | Candidate for delivering the custom email fallback | Evaluate email transport separately from the application's generation, storage, expiration, and verification of fallback codes. |
| Datadog | Candidate for collecting the application's reset evidence | Compare search, access, and retention requirements; observability does not itself authorize a password reset. |
These are selection responsibilities, not a claim that the products are interchangeable. The Twilio plus Datadog alternative entails two service signups and two sets of credentials. The application supplies the glue: attach a shared attempt identifier, translate outcomes into its evidence model, and coordinate retry behavior between dispatch and telemetry. That separation may suit a team that already operates both services. Review the linked product documentation before selecting configuration or regional terms.
Infrai offers one API key and one bill across SMS and observability: the same key sends the challenge and records its evidence. Its breadth is real: 295 routes across 20 modules under one key. This unified API means one integration can cover both steps over plain HTTP without an SDK, rather than managing separate credentials for each backend service. Public discovery supplies request and response schemas, which helps a Python team move from notebook to production without guessing request fields; the combined choice also means one vendor to trust and one outage surface.
The application still owns the reset policy. Use managed SMS verification for the primary path, implement the email fallback's code lifecycle explicitly, and poll channel events to collect delivery evidence. Account for polling delay when deciding whether fallback still has useful time remaining. Apply geographic eligibility, country-based spending cutoffs, and anti-abuse throttles in the application before dispatch. A country allowance or budget check is an operational control, not proof of compliance.
One Python handoff, with a narrow evidence claim
The focused example below sends an SMS OTP request and uses a digest of its successful response as input to log ingestion, with the same key and base URL. It intentionally records a response fingerprint rather than a phone number or code. The fingerprint demonstrates the handoff; it does not prove delivery or replace subsequent event collection and verification.
Request fields must come from the published schemas. Set SMS_OTP_PARAMS to a valid SMS request JSON object and RESET_LOG_PARAMS to a valid log-ingestion JSON object. In string fields allowed by the log schema, include the markers RESET_ATTEMPT_ID and SMS_RESPONSE_SHA256. The program replaces those markers with the attempt identifier and response digest. This keeps the example runnable without inventing provider field names. Both payloads must already satisfy their respective schemas, including any supported expiry configuration.
Install httpx in the Python environment. Set COMM_API_BASE_URL to the documented API base including its version prefix, and supply INFRAI_API_KEY through the environment. Use synthetic recipients during evaluation, and preserve RESET_ATTEMPT_ID if retrying this same logical attempt. A different attempt needs a different identifier.
import hashlib
import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
import httpx
BASE_URL = os.environ["COMM_API_BASE_URL"].rstrip("/")
KEY = os.environ["INFRAI_API_KEY"]
ATTEMPT = os.environ["RESET_ATTEMPT_ID"]
def retry_delay(value, fallback):
if value is None:
return fallback
try:
return max(0.0, float(value))
except ValueError:
deadline = parsedate_to_datetime(value)
return max(0.0, (deadline - datetime.now(timezone.utc)).total_seconds())
def post(client, path, payload, operation):
headers = {
"Authorization": f"Bearer {KEY}",
"Idempotency-Key": f"{ATTEMPT}:{operation}",
}
for retry in range(4):
response = client.request(
method="POST",
url=BASE_URL + path,
headers=headers,
json=payload,
)
if response.status_code == 429 and retry < 3:
time.sleep(retry_delay(response.headers.get("Retry-After"), 2 ** retry))
continue
if not response.is_success:
raise RuntimeError(
f"{operation}: HTTP {response.status_code}: {response.text}"
)
return response
def fill(value, replacements):
if isinstance(value, str):
for marker, replacement in replacements.items():
value = value.replace(marker, replacement)
return value
if isinstance(value, list):
return [fill(item, replacements) for item in value]
if isinstance(value, dict):
return {key: fill(item, replacements) for key, item in value.items()}
return value
sms_params = json.loads(os.environ["SMS_OTP_PARAMS"])
log_template = json.loads(os.environ["RESET_LOG_PARAMS"])
if not isinstance(sms_params, dict) or not isinstance(log_template, dict):
raise ValueError("Both request payloads must be JSON objects")
serialized = json.dumps(log_template)
for required_marker in ("RESET_ATTEMPT_ID", "SMS_RESPONSE_SHA256"):
if required_marker not in serialized:
raise ValueError(f"Missing log marker: {required_marker}")
with httpx.Client(timeout=15.0) as client:
sms_response = post(client, "/sms/otp", sms_params, "sms")
digest = hashlib.sha256(sms_response.content).hexdigest()
log_params = fill(log_template, {
"RESET_ATTEMPT_ID": ATTEMPT,
"SMS_RESPONSE_SHA256": digest,
})
post(client, "/logs/ingest", log_params, "evidence")
print("Dispatch response fingerprint recorded")
The two writes are separate operations. This small program is a handoff demonstration, not a complete reset service: production code should persist the successful dispatch outcome and prepared evidence record before retrying an interrupted evidence write. Retrying telemetry must not initiate another challenge. Keep the same idempotency key and payload for a retry of the same operation, and verify each capability's idempotency contract before relying on deduplication.
A response digest also has a limit: without a retained source record, it cannot reconstruct the response. Decide whether that fingerprint is useful under the evidence policy.
Secrets stay out.
Never treat hashing as permission to retain credentials, and never send raw reset codes to a support summarizer.
Measure authorization evidence before copying the choice
The notebook-to-prod gate should exercise a late message, a replacement request, an expired code, an exhausted attempt allowance, and an interrupted evidence write. These are proposed test cases, not measured results. Check whether each resulting record explains the decision without exposing the reset secret. Test the edge of the hypothetical 180-second deadline, including a delivery observation made after expiration. For example, let the test clock reach 179 seconds, start a replacement, and then advance beyond the original deadline before submitting either code. The expected result follows the policy above: replacement invalidates the old challenge, and neither challenge authorizes a reset after the original deadline. This catches a specific trap in channel orchestration: creating a fresh email credential with a fresh lifetime can accidentally turn fallback into an extension of the reset window.
Measure request acceptance, observed delivery, and verified completion separately. Track the delay between event occurrence and observation where timestamps permit it, plus duplicate challenge creation and missing evidence records. For email, review domain authentication against DMARC and avoid using opens as the completion signal; Apple's Mail Privacy Protection is relevant when interpreting email activity. A delivery event remains different from successful verification.
Keep the eval-driven harness deterministic. If an AI support feature consumes these records, provide a compact, redacted timeline and measure its prompt-token budget separately from authentication outcomes. That makes the workflow prompt-cost aware without putting a language model in the authorization path. The most useful result is boring: an expired code is rejected, the record explains why, and fallback cannot change the deadline by accident.
Choose the combined surface if shared credentials and a common evidence destination reduce integration work under your access and retention requirements. Choose separate services if existing controls make their extra correlation glue acceptable. In either case, compliance evidence comes from the complete application workflow and its reviewed operating terms, not the presence of a send API.
Sources
References:
Top comments (0)