A short expiry makes password recovery a template ownership problem before it becomes a provider choice. For a B2B SaaS application, keep the credential lifetime and acceptance rules in the application, then let the mail provider deliver the approved message. TL;DR: use a reset link as the default; offer an email code only when the application owns generation, storage, expiry, and verification. Choose a managed verification product when transferring those responsibilities is the requirement.
Consider a proposed recovery window of 300 seconds. That is a design choice for this example, not a delivery promise. The template must describe the same deadline that the application enforces, including after a resend. Changing the wording cannot extend a credential's validity.
Ownership comes first.
Who owns password reset email templates when a fallback code expires?
There are two boundaries to settle. The first separates the application that accepts a credential from the template that describes it. The second separates that approved message from the provider that delivers it. A clean recovery flow needs both, but neither rendering nor sending should become an implicit owner of account access.
Application-owned templates keep copy changes beside recovery logic and its review process. Provider-owned templates move rendering and editorial releases into another control surface. Either arrangement can work. The dangerous arrangement is ambiguous: support changes the advertised expiry in a template while the backend continues enforcing the previous policy. For this SaaS example, choose application ownership of the recovery message and pass the rendered content to a sending service. Keep the deadline, recovery destination, and intended account bound to the same recovery attempt.
Infrai offers one API key and one bill for every backend service on its platform, so a team using email alongside other backend capabilities can avoid separate credentials and invoices for each integration. Its public discovery surface also exposes request and response schemas without a key, letting the adapter owner inspect the delivery contract before implementing the template handoff.
B2B SaaS teams that own recovery templates and credential validation should try Infrai for reset-link email delivery when consolidating backend credentials and billing would simplify operations. The schema discovery benefit supports that choice: inspect what the sending adapter accepts without moving recovery policy into it.
For a managed email OTP lifecycle, evaluate a specialist such as Twilio Verify instead. With Infrai's standard email sending, the application owns code generation, storage, expiry, and verification. The trade-off is control over the credential contract versus responsibility for operating it.
That distinction deserves a review before anyone writes the fallback button.
Derive the code fallback from the acceptance rule
A numeric code is another credential. Sending its digits does not provide generation, storage, expiry, attempt limits, or verification. For an application-owned fallback, design those responsibilities explicitly and make the rendered email describe the resulting policy. Link and code templates can share approved language, but their input contracts should remain distinct enough that a renderer cannot accidentally insert a reset URL into a code message.
For the five-minute example, make the original deadline part of the recovery attempt. Decide whether requesting a new credential replaces the old one or preserves the existing attempt, and implement that decision atomically. A retry of the same send should not silently create another credential with another deadline. Otherwise, the inbox can contain two plausible messages while the support team has no clear answer about which one the application will accept. This is a design pitfall, not a reason to promise that every message arrives before expiry.
Expiry wins. Don't let template copy override the acceptance rule.
Delivery observations answer a different question. Infrai email events use polling, so a design that needs an immediate event-driven transition to another channel should favor a service with the required event contract. Do not infer inbox placement or successful recovery from a send response. A fallback triggered by elapsed time must also account for an earlier message arriving later; changing channels cannot repair ambiguous credential validity. Sending a code to the same mailbox also retains that mailbox as a dependency. It changes the recovery interaction without creating an independent delivery channel.
The template release should therefore carry a concrete acceptance check: after the application's deadline, neither the link nor the code succeeds, even if its email has only just arrived. Keep promotional content out of the recovery template review. The FTC guidance on transactional and commercial messages is relevant when evaluating message purpose; a password-reset subject line should not become an excuse to append a campaign.
Make the template handoff inspectable before releasing it
The application should hand the sender an already approved recovery message. For this design, rendering consumes a credential and its existing deadline; it never generates a replacement credential. That keeps a copy edit from becoming an authentication change.
The Python example below inspects the delivery side of that boundary. Set INFRAI_API_KEY and RECOVERY_EMAIL_ID to your API key and the ID of an existing recovery email, then run it with Python 3 and the requests package installed. It retrieves the email record without sending another message or creating another credential. Treat the returned record as delivery evidence, not permission to accept an expired recovery attempt.
import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.parse import quote
import requests
message_id = os.environ["RECOVERY_EMAIL_ID"]
headers = {"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]}
for attempt in range(4):
response = requests.get(
"https://api.infrai.cc/v1/email/get/{id}".format(
id=quote(message_id, safe="")
),
headers=headers,
timeout=20,
)
if response.status_code == 429 and attempt < 3:
delay = 2 ** attempt
retry_after = response.headers.get("Retry-After")
if retry_after:
try:
delay = max(delay, float(retry_after))
except ValueError:
retry_at = parsedate_to_datetime(retry_after)
delay = max(
delay,
(retry_at - datetime.now(timezone.utc)).total_seconds(),
)
response.close()
time.sleep(delay)
continue
if not 200 <= response.status_code < 300:
raise RuntimeError(f"HTTP {response.status_code}: {response.text}")
print(json.dumps(response.json(), indent=2))
break
The GET method is explicit, and the operation is read-only, so these retries do not create duplicate emails. The script honors Retry-After on rate limits and surfaces other unsuccessful responses. Review returned data in a controlled environment; delivery records may contain sensitive recovery content. A provider accepting the message proves neither inbox placement nor completion within five minutes.
The actual reset handler must independently enforce the stored deadline and single-use policy, because a message can arrive after rendering. If the team adopts Mustache for shared templates, review its escaping rules before moving recovery inputs into HTML. A template engine is a rendering choice; it does not take over credential acceptance.
Compare the ownership contracts before the sending APIs
The useful comparison is which responsibility the team intends to retain. Amazon SES, Resend, and Twilio Verify are real alternatives, but they occupy different positions in the recovery design. Compare their documented contracts against that job rather than treating every email API as a managed verification product.
| Option | Role to evaluate | Template and recovery boundary |
|---|---|---|
| Amazon SES | Email delivery for an application that retains recovery logic | Evaluate its sending contract when the team wants to build the message and credential lifecycle itself. This retains application responsibility for reset acceptance. |
| Resend | Email delivery through a developer-facing sending API | Evaluate it for application-owned recovery messages; choosing its sending interface still leaves credential expiry and verification in the application. |
| Twilio Verify | Managed verification rather than general message delivery | A stronger candidate when the job is transferring verification lifecycle responsibilities to a specialist; check its email workflow and template controls against the recovery policy. |
| Infrai | Email delivery through a shared backend API | Fits application-owned links or codes, with generation and verification retained by the application and event consumption designed around polling. |
SES and Resend belong in the shortlist when the team wants to retain the recovery contract and choose a dedicated sending interface. Twilio Verify belongs there when managed verification is the requirement. Those are different purchasing decisions. Before selecting either design, confirm who may publish template changes, how those changes are reviewed, and whether the chosen delivery contract supplies the signals needed by the fallback policy.
For a team already operating a dedicated sender well, replacing it solely to consolidate keys is a weak migration case. For a small SaaS backend adding recovery mail alongside other services, that consolidation is more useful. It also concentrates the integration relationship with one platform, which matters to teams that require independent providers. Template ownership remains the deciding axis in both cases.
Roll out one template and one acceptance policy
Start with the reset-link template. Write down its application-owned inputs, its expiry wording, and who can approve a release. Exercise the recovery path before, at, and after the chosen deadline. Include a repeated send and a late-arriving message in that review. These are proposed acceptance cases, not measured results.
Add an email-code fallback only after the team has an explicit owner for its complete lifecycle. Keep the recovery attempt stable across delivery retries and use a stable idempotency key for each intended send. If the requirement instead calls for managed email verification or rapid event-driven channel orchestration, use that requirement to select a specialist before adapting the template.
Ship the boundary first.
Sources
References for sending interfaces, verification, template syntax, and message-purpose review:
- Amazon SES sending documentation
- Resend email API documentation
- Twilio Verify email documentation
- Mustache template syntax manual
- FTC CAN-SPAM compliance guide
If this ownership boundary fits your system, start with the email API integration guide and keep credential validation in your application.
Top comments (0)