Choose backend-owned SMS authentication templates for a property-management contact form when your team can also own delivery polling, failed-send decisions, and the wording tenants see. Template ownership is the deciding constraint: support needs to approve what a tenant reads before a verified request reaches the right queue.
Short answer: keep tenant-facing message policy with the application, send the OTP, and poll delivery status before offering a retry or another login option. Choose hosted template ownership instead when its approval and release process better matches the people responsible for those messages. This recommendation assumes scheduled checks are acceptable; it doesn't fit a requirement for immediate orchestration across SMS, voice, and chat apps.
A message saying that a code was delivered and a message saying that a support request was submitted describe different events. Give them different copy. Otherwise, an unverified tenant may believe maintenance already has the request.
How should a backend handle failed SMS 2FA login delivery status?
Start with the words. A tenant selects a property, chooses a support category, and requests an SMS 2FA login code before submitting the contact form. These are illustrative application choices, not a provider schema. The property and category determine the eventual support queue; the delivery receipt doesn't.
The application should own a versioned mapping from an internal event to an approved sentence. A pending check can say, “We are checking your code delivery.” A failed send can offer a controlled retry. Successful code verification can unlock submission. Only the application's actual submission result should trigger “Your request was submitted.” Template ownership matters because these messages cross different trust boundaries, yet the tenant experiences them as one conversation with the property manager.
Keep those distinctions.
Backend ownership gives the team one place to review that mapping alongside routing policy. The trade-off is work: someone must maintain copy versions, polling deadlines, retry eligibility, and the alternate-login decision. A hosted template workflow is preferable if it gives the actual copy approvers a better release process and the application can still record which approved version it selected. Template location alone doesn't settle who has authority to change a sentence.
Before and after: make delivery evidence explainable
Before: contact form → send code → show reassuring copy → leave support to interpret an ambiguous complaint.
After: contact form → send code → scheduled status/event checks → choose delivery-aware copy → verify the code → route the submitted request.
The useful change is the explicit decision between evidence and wording. A send attempt isn't verification. A successful delivery report isn't permission to submit a support request. Conversely, a polling deadline means the application stopped waiting; it doesn't prove that a carrier rejected the message. Preserve an unknown state.
Infrai offers a plain REST API with no SDK to install, plus a single key and unified billing across 295 routes and 20 modules. The backend can use ordinary HTTP requests without maintaining a provider client-library version. For a contact-form service using both SMS and email, the one API key and one bill mean one credential to configure and a single invoice to reconcile for those integrations. The trade-off is that the application still owns tenant wording, failed-send retries, and verification policy. This workflow uses scheduled polling to drive delivery-aware branching.
Its public discovery surface supplies request and response schemas without an API key. Use those schemas to review the adapter that translates delivery evidence into tenant-facing copy.
For observability, record an application attempt identifier, the selected copy version, the queue decision, and the time of each observation. Keep the OTP and full tenant message out of that diagnostic record. Count polling deadlines separately from confirmed failed sends; otherwise an alert can blame message delivery for a delayed observation. These are application design recommendations, not promises about a provider's dashboard or automatic instrumentation.
Walk through one copyable policy example
This TypeScript example runs locally and makes no network requests. Its input names are application-owned normalized states. A provider adapter must translate documented responses into those states; the example makes no assumptions about response field names. The deadline of 30 seconds and two observations are illustrative choices, not delivery guarantees or OTP expiry settings. The failure observation arrives at 12 seconds in this synthetic input; it is not a measured provider latency.
type DeliveryEvidence = "pending" | "failed" | "delivered";
type Observation = {
evidence: DeliveryEvidence;
elapsedMs: number;
};
type Decision = {
copyVersion: string;
message: string;
action: "poll" | "offer_retry" | "offer_alternate" | "await_code";
};
function chooseMessage(
observation: Observation,
deadlineMs: number,
retryAllowed: boolean
): Decision {
const copyVersion = "tenant-login-v1";
if (observation.evidence === "delivered") {
return {
copyVersion,
message: "Enter your code to continue.",
action: "await_code"
};
}
if (observation.evidence === "failed") {
return {
copyVersion,
message: retryAllowed
? "Your code could not be delivered. You can request another."
: "Your code could not be delivered. Choose another login option.",
action: retryAllowed ? "offer_retry" : "offer_alternate"
};
}
if (observation.elapsedMs >= deadlineMs) {
return {
copyVersion,
message: "Delivery is still unconfirmed. Choose another login option.",
action: "offer_alternate"
};
}
return {
copyVersion,
message: "We are checking your code delivery.",
action: "poll"
};
}
const request = {
attemptId: "example-attempt-001",
property: "Maple Court",
category: "maintenance",
proposedQueue: "maple-maintenance"
};
const observations: Observation[] = [
{ evidence: "pending", elapsedMs: 0 },
{ evidence: "failed", elapsedMs: 12000 }
];
for (const observation of observations) {
const decision = chooseMessage(observation, 30000, true);
console.log(JSON.stringify({
attemptId: request.attemptId,
proposedQueue: request.proposedQueue,
evidence: observation.evidence,
elapsedMs: observation.elapsedMs,
copyVersion: decision.copyVersion,
action: decision.action,
message: decision.message
}));
}
The first observation selects checking copy. The second selects a retry offer. Neither routes the request or marks the tenant verified. That's the point: a message-policy function shouldn't quietly become an authorization function.
No verification, no routing.
Wire a production adapter to the documented OTP send, delivery status/event, resend, and verification operations. Schedule bounded checks after sending. Distinguish an intentional resend from repeating the same transport attempt, and apply the documented idempotency rules to writes. Respect rate limits with delayed retries and backoff. Keep verification and contact-form submission as explicit subsequent steps.
For the read side, this second TypeScript snippet fetches the documented delivery-status resource and prints the response without inventing its fields. Set INFRAI_BASE_URL to the documented API base ending in /v1, INFRAI_API_KEY to your credential, and SMS_ID to the identifier returned by your send integration. Run it in a TypeScript runtime with native fetch support. It makes up to 4 attempts, honors a valid Retry-After header, and surfaces non-success response bodies. Don't schedule another check until this bounded read finishes.
async function readDeliveryStatus(): Promise<unknown> {
const base = process.env.INFRAI_BASE_URL;
const key = process.env.INFRAI_API_KEY;
const id = process.env.SMS_ID;
if (!base || !key || !id) {
throw new Error("Set INFRAI_BASE_URL, INFRAI_API_KEY, and SMS_ID");
}
const url = new URL(`${base.replace(/\/$/, "")}/sms/status/${encodeURIComponent(id)}`);
if (url.protocol !== "https:") {
throw new Error("The API base must use HTTPS");
}
for (let attempt = 0; attempt < 4; attempt++) {
const response = await fetch(url, {
method: "GET",
headers: { Authorization: `Bearer ${key}` },
signal: AbortSignal.timeout(10000)
});
const body = await response.text();
if (response.status === 429 && attempt < 3) {
const retryAfter = response.headers.get("Retry-After");
let delayMs = 1000 * 2 ** attempt;
if (retryAfter !== null) {
const seconds = Number(retryAfter);
const retryAt = Date.parse(retryAfter);
if (Number.isFinite(seconds) && seconds >= 0) {
delayMs = Math.max(delayMs, seconds * 1000);
} else if (Number.isFinite(retryAt)) {
delayMs = Math.max(delayMs, retryAt - Date.now());
}
}
await new Promise(resolve => setTimeout(resolve, delayMs));
continue;
}
if (!response.ok) {
throw new Error(`Status read failed: ${response.status} ${body}`);
}
return JSON.parse(body);
}
throw new Error("Status read exhausted its attempt budget");
}
readDeliveryStatus()
.then(value => console.log(JSON.stringify(value)))
.catch(error => {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
});
Inspect that response against the current schema before writing the normalization adapter. Printing it is a development inspection step, not a production logging policy. Production diagnostics should retain only the evidence needed to explain a decision.
Would a specialist provider make template ownership easier?
Possibly. Compare ownership with an acceptance test. Ask the person who approves tenant copy to change one sentence, then establish which release carried it, which attempt selected it, and which observation selected the visible message. Repeat that exercise with each candidate.
| Candidate | Ownership question to test | Selection boundary |
|---|---|---|
| Twilio Verify | Can the proposed verification setup preserve the copy approval and version evidence this support workflow needs? | Prefer a verification service when its documented template controls match the approvers' needs; validate customization constraints before committing. |
| Amazon SNS | Can the proposed messaging integration preserve the same application-owned policy and delivery evidence? | Prefer a messaging integration when the team wants to own the surrounding OTP generation, verification, and tenant-copy decisions. |
| Vonage Verify | Can the proposed verification workflow keep tenant wording and retry decisions auditable together? | Prefer its verification workflow if its documented configuration matches the approval process; validate template and workflow restrictions for the intended account. |
These are different integration evaluations: a verification workflow, a messaging integration, and another verification workflow. They aren't a claim that every candidate supplies all the template controls, delivery mechanisms, or fallback channels discussed here. Check current documentation and exercise the actual account configuration before deciding. The table identifies what to validate; it doesn't establish feature parity.
For this scenario, prefer backend ownership because it keeps the copy decision next to the support-routing decision. Choose a hosted alternative if the acceptance test shows that copy approvers can work more effectively there while preserving the evidence your team needs. A provider's brand cannot settle that organizational question.
Can retries and fallback stay simple?
Yes, if the scope stays narrow. Offer a resend only after applying application-level cooldowns, attempt limits, and country eligibility rules. Enforce country-based spending limits in the backend too. Keep a repeated transport request tied to its original idempotency key; treat a deliberate new OTP attempt as a separate decision. Otherwise a tenant's repeated clicks can produce more sends than the interface suggests.
An alternate email-code path needs its own application-owned code lifecycle and verification policy. It isn't just a different message template. Review the OWASP guidance for expiring, single-use codes, and review sender requirements before treating email as a dependable fallback. Keep scheduled-message cancellation out of the login decision: resend and verification are the relevant operations here.
For this HTTP-and-polling design, plan scheduled observations rather than webhook-driven branching. If immediate coordination across SMS, voice, and chat apps is a requirement, evaluate a service designed for that scope. Also evaluate regional compliance independently of a provider's breadth, keep an application-owned template-version registry, and collect the application tags needed for your own spending reports. None of those decisions belongs in a reassuring tenant sentence.
Make that sentence explainable. The useful diagnostic question is precise: which approved copy version did this attempt select, from which observation, before the verified form reached which support queue?
Top comments (0)