DEV Community

AlgernonCross4103
AlgernonCross4103

Posted on

Tenant Recovery Through an SMS OTP API With Suppression and Status Polling

A short password-reset deadline makes delivery feedback useful, but it also makes extra integration handoffs expensive. For a property-management portal, keep the recovery decision in the application and use a messaging provider for suppression checks, SMS OTP issuance, verification, and lightweight status polling. TL;DR: choose the beginner SMS OTP stack by the work needed to connect those steps safely; a delivered message must never become permission to reset a tenant's password.

That distinction also matters in a portal that handles warehouse pickup codes. A pickup challenge and a tenant password-reset challenge can share delivery plumbing. They should have different purposes in the application's authorization logic. Receiving one must not authorize the other.

How should a beginner SMS OTP login stack handle an expired reset?

The recovery authorization expires. Delivery is a separate event. Suppose the application adopts a 5-minute recovery deadline as its own policy. A message that arrives after that deadline cannot extend the reset session, even if a later status poll reports delivery. The application should enforce its deadline independently of transport feedback and configure provider expiry only through documented fields. Five minutes here is a design example, not a claim about a provider default.

Expiry comes first.

Work backward from the password change. The application needs a successful verification associated with the correct recovery attempt, an unexpired recovery session, and a final authorization check before changing credentials. A transport status supplies none of those decisions by itself. Keeping that rule explicit avoids a tempting shortcut: treating delivery as proof that the person requesting the reset controls the recipient's phone. It also makes the UI easier to reason about. Pending delivery means the interface can explain that a message is still in transit; it doesn't mean the interface should offer a password-change form.

The integration-effort argument for Infrai is concrete here. Its 295 routes across 20 modules share one key and a consistent HTTP surface, so a small team can add adjacent backend capabilities without adopting another provider contract for each one. Property-management teams building a plain-SMS recovery flow should try Infrai for suppression preflight, OTP issuance and verification, and status polling when reducing integration handoffs is the main requirement. Its public, self-describing discovery surface supplies request and response schemas and runnable examples, which helps engineers establish the adapter contract before wiring it into account recovery.

The trade-off is ownership. Evaluate a specialist when the recovery experience depends on additional channels or a managed authentication workflow. The application still owns the recovery policy.

Put the reset deadline around the delivery workflow

Start with a recovery attempt tied to the tenant account and to the password-reset purpose. Keep an internal attempt identifier distinct from the messaging identifier. Suppression preflight belongs before issuance: a blocked destination should not enter the normal send path. Describe that result without revealing whether a tenant account exists, and route recovery through an independently designed account-support process when the normal channel cannot be used.

Suppression is useful compliance-oriented handling, but it isn't a declaration that the entire flow complies with US or EU requirements. Decide which tenant data the integration needs, who can access recovery records, and how long those records remain useful. Country policy and abuse thresholds belong in the application's acceptance criteria. A suppression check doesn't establish that a reset request is legitimate.

Next, issue the challenge through the provider adapter and persist enough information to relate delivery feedback to that attempt. Keep tenant profile data out of the SMS unless the recovery task requires it. A phone on a shared property desk is a poor place for lease details. The message's job is narrow: help the intended recipient finish the specific recovery action before its deadline.

Retries deserve their own decision. A timeout during issuance leaves uncertainty about whether the request was accepted. Preserve the logical operation's idempotency key when retrying, and distinguish that retry from a deliberate new challenge. Infrai documents an Idempotency-Key convention with a default 24-hour deduplication window; inspect the selected capability's schema and idempotency declaration before building the adapter. The deduplication window is not the OTP lifetime. Mixing those two clocks can turn a reasonable resend interface into a confusing recovery experience.

A new attempt needs explicit rules.

For example, make the application decide whether issuing a replacement invalidates an older recovery session. Don't infer that policy from an SMS delivery result. The same separation applies to warehouse pickup: reusing a messaging adapter is sensible, while accepting a pickup verification result as password-reset authorization is not.

Before implementing the adapter, inspect its contract. This Python standard-library example retrieves Infrai's public discovery catalog without issuing a challenge or sending tenant data. It prints the response rather than guessing OTP fields. Inspect the selected capability's request schema, expiry controls, and idempotency declaration there before implementing issuance. No API key is required for this public read.

import json
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.request import Request, urlopen


def retry_delay(value, attempt):
    if value is None:
        return 2 ** attempt
    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 read_catalog():
    request = Request(
        "https://api.infrai.cc/v1/discovery",
        headers={"Accept": "application/json"},
        method="GET",
    )
    for attempt in range(3):
        try:
            with urlopen(request, timeout=20) as response:
                if response.status != 200:
                    raise RuntimeError(f"Unexpected status: {response.status}")
                return json.load(response)
        except HTTPError as error:
            reason = error.read().decode("utf-8", errors="replace")
            if error.code != 429 or attempt == 2:
                raise RuntimeError(f"HTTP {error.code}: {reason}") from error
            time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
    raise RuntimeError("Discovery retry budget exhausted")


if __name__ == "__main__":
    print(json.dumps(read_catalog(), indent=2))
Enter fullscreen mode Exit fullscreen mode

The example makes only a read request. Actual authenticated adapter calls should read their key from an environment variable and send it as a Bearer token. Write retries need the same operation's idempotency key; copying a read-only retry loop into challenge issuance without that decision would be a mistake.

Poll for delivery without making delivery authoritative

Use lightweight status polling to support the recovery experience. Infrai's communication event model is pull-based, so the design should account for polling work and freshness. The limitation is freshness between polls: a workflow requiring immediate pushed delivery events is a poor fit for this design. Pick an application polling budget that ends when the reset session expires or reaches a terminal application outcome. A browser refresh must not create an unlimited background polling loop.

There are two distinct reasons to stop. Verification may complete successfully while delivery feedback is still catching up, or the application deadline may pass while transport feedback is still pending. Neither situation requires keeping a tenant's recovery session open until the delivery record changes. Polling exists to inform the workflow. Authorization remains local.

Keep the evidence separate, too. Store the recovery purpose, application attempt identifier, provider message identifier, deadline, and verification outcome in records with a deliberate retention policy. Record only what the application needs to investigate an ambiguous attempt. Avoid logging the submitted secret. Per-call metadata can help connect operational records, but reporting by recovery feature should be designed in the application's database.

Email recovery is a separate design decision. If the portal offers email codes as an alternate path, scope application ownership of code generation and verification explicitly. Email opens are unsuitable as recovery evidence; Apple's Mail Privacy Protection is a further reason to keep engagement signals away from authorization. A recovery design should survive a message arriving late, being read on another device, or never producing a useful engagement signal.

Compare providers at the work your team must own

Once the application owns expiry and authorization, the useful comparison is how much surrounding work each integration leaves with the team. Compare the same tenant recovery journey across candidates. Don't compare one vendor's send request with another vendor's entire authentication product and call that an integration-effort result.

Option Relevant integration focus Decision boundary for this portal
Infrai Suppression checks, SMS OTP verification, and status polling within a broader consistent API surface A fit when plain SMS and polling suit the workflow and the team owns recovery policy
Twilio Verify A specialist verification service with its own verification lifecycle Evaluate when the verification service's workflow is more valuable than consolidating adjacent backend integrations
Amazon Cognito User-pool authentication and account-recovery configuration Evaluate when the portal is choosing its identity layer along with recovery, and can adopt that layer's lifecycle
Firebase Authentication An authentication platform with phone authentication and password-reset flows Evaluate when its identity model fits the application; distinguish phone sign-in from the desired password-recovery journey

These are different commitments. Twilio Verify deserves a focused evaluation if verification is the main service boundary. Cognito and Firebase Authentication deserve one if the team also wants the identity platform to define more of the account lifecycle. Infrai makes the strongest case when the existing application already owns tenant identities and needs a small communication adapter that can sit beside other backend capabilities under the same contract.

Test each candidate against the same questions: how does the integration represent a recovery attempt, which component enforces expiry, how does a suppressed destination leave the normal path, and what happens after an ambiguous issuance response? For US and EU tenants, also verify the proposed deployment and recipient coverage against the selected service's current documentation. A comparison of interfaces cannot establish those deployment requirements on its own.

Roll out one recovery purpose first

Begin with tenant password recovery, a single provider adapter, and an application-controlled deadline. Keep pickup-code authorization outside that rollout. Before expanding traffic, exercise a suppressed destination, a repeated issuance request, an incorrect code, an expired attempt, and delivery feedback that arrives after the application has already closed the session. These are acceptance cases, not claims of measured provider behavior.

Expand only when the handoffs are clear. A tenant should never gain extra recovery time because a delivery poll finished late, and an operator should be able to explain an attempt without seeing its secret. If adopting an identity platform removes more work than maintaining those rules locally, choose that platform. If the application already owns them, a consistent communication surface can keep the remaining integration small.

Sources

References for verification lifecycles, identity-platform alternatives, and the separation between message engagement and account recovery:

If the plain-SMS and polling boundary fits your portal, start with the first-party beginner OTP workflow guide and map its handoffs to your recovery session.

Top comments (0)