Keep DNS writes and sending-domain verification in one onboarding flow, but let zone ownership decide who performs the writes. For a B2B SaaS hostname cutover, a customer-controlled zone needs an instructions path; a platform-controlled zone can use an automated path. Both need the same activation gate and a retained rollback target.
TL;DR: Bundle DNS setup and mail verification behind one credential where you have authority to change the records. Read the sending domain's status back before activating it. A single onboarding step describes the customer's experience, not a promise that every underlying operation completes together.
An LLM feature can produce a useful customer report and still leave onboarding unfinished if its sending domain isn't ready. The practical concern here is delivery setup: don't spend another model call explaining a success screen that your application cannot substantiate. Keep the control decision in ordinary application logic.
How should sending domain setup fit into one onboarding step?
Ownership is the first branch. Suppose the proposed sending hostname is reports.customer.example, while reports.platform.example remains the current application-selected sender. These are illustrative names, not deployed domains. The customer may authorize your service to manage the required records, or may insist on entering them independently. Treat that choice as part of onboarding rather than an exception that support has to resolve later.
One flow can coordinate DNS writes, request sending-domain verification, and read the sending domain's status back to drive the UI. Keep those responsibilities separate inside the flow. Record submission is evidence of an attempted change; the status read supplies the evidence used for activation. Neither is permission to modify an unrelated customer record.
Keep both paths.
Customer authority wins.
For a platform-managed zone, the application can arrange the authorized DNS changes itself. For a customer-managed zone without delegated access, it should display the required records and wait for the customer's action. That customer still sees one onboarding task. Requiring them to grant broader access just to make the progress indicator look tidy would be a poor trade.
The data flow is deliberately small: capture the proposed hostname and current sender, choose automated writes or customer instructions, request verification after the record step, then read status and activate only when the application has positive evidence. Keep the previous sender in application state so the routing decision can be reversed. This is an application rollback plan; it does not imply that DNS changes and mail verification share a transaction.
Make the activation decision executable first
The following TypeScript program implements the local gate. Save it as onboarding.ts and run it with npx tsx onboarding.ts. It needs no credentials. The two cases represent alternative observations for the same proposed cutover, so they can be compared without modifying a live zone.
The boolean inputs belong to this application's model. They are not provider response fields. An integration must derive them from the documented record workflow and a fresh sending-domain status read; the example makes no claim about the spelling of a vendor's status values.
type ZoneControl = "platform" | "customer"; type Cutover = { zoneControl: ZoneControl; currentSender: string; proposedSender: string; recordsStepComplete: boolean; sendingDomainVerified: boolean; }; type Decision = { activeSender: string; rollbackSender: string; nextAction: "write-records" | "show-instructions" | "verify" | "activate"; }; function decide(input: Cutover): Decision { const base = { activeSender: input.currentSender, rollbackSender: input.currentSender, }; if (!input.recordsStepComplete) { return { ...base, nextAction: input.zoneControl === "platform" ? "write-records" : "show-instructions", }; } if (!input.sendingDomainVerified) { return { ...base, nextAction: "verify" }; } return { ...base, activeSender: input.proposedSender, nextAction: "activate", }; } const proposal: Cutover = { zoneControl: "customer", currentSender: "reports.platform.example", proposedSender: "reports.customer.example", recordsStepComplete: false, sendingDomainVerified: false, }; const awaitingCustomer = decide(proposal); const readyToActivate = decide({ ...proposal, recordsStepComplete: true, sendingDomainVerified: true, }); if (awaitingCustomer.activeSender !== proposal.currentSender) { throw new Error("An incomplete setup must retain the current sender"); } if (readyToActivate.rollbackSender !== proposal.currentSender) { throw new Error("Activation must preserve the previous sender"); } console.log(JSON.stringify({ awaitingCustomer, readyToActivate }, null, 2)); The boundary matters more than the function's size. A successful write must not set sendingDomainVerified. A customer clicking “I've added the records” must not set it either. Those events can advance the record step and trigger verification, but activation still depends on reading status back. Otherwise, the program would encode the very assumption the onboarding flow is supposed to remove.
There are two independent decisions here: who can change records, and whether the proposed sending domain is ready. Collapsing them into one “connected” flag makes it difficult to explain why the current hostname is still active. Keeping them separate also means a customer can complete the instructions path without handing over control of the zone.
The network boundary can be exercised separately with this read-only status probe. Set INFRAI_API_ORIGIN to the service's API origin, INFRAI_API_KEY to your credential, and SENDING_DOMAIN to the registered domain. It prints the returned JSON for inspection; it does not guess which response field means verified. Wire that mapping into the local gate only after checking the response schema.
async function readSendingDomain(): Promise<void> { const origin = process.env.INFRAI_API_ORIGIN; const apiKey = process.env.INFRAI_API_KEY; const domain = process.env.SENDING_DOMAIN; if (!origin || !apiKey || !domain) { throw new Error("Set INFRAI_API_ORIGIN, INFRAI_API_KEY, and SENDING_DOMAIN"); } const url = new URL( `/v1/email/domain/get/${encodeURIComponent(domain)}`, origin, ); if (url.protocol !== "https:") { throw new Error("The API origin must use HTTPS"); } for (let attempt = 0; attempt < 3; attempt += 1) { const response = await fetch(url, { method: "GET", headers: { Authorization: `Bearer ${apiKey}` }, signal: AbortSignal.timeout(15000), }); if (response.status === 429 && attempt < 2) { const retryAfter = response.headers.get("Retry-After"); const seconds = retryAfter === null ? NaN : Number(retryAfter); const dateDelay = retryAfter === null ? NaN : Date.parse(retryAfter) - Date.now(); const delay = Number.isFinite(seconds) ? Math.max(0, seconds * 1000) : Number.isFinite(dateDelay) ? Math.max(0, dateDelay) : 1000 * 2 ** attempt; await response.body?.cancel(); await new Promise((resolve) => setTimeout(resolve, delay)); continue; } const body = await response.text(); if (!response.ok) { throw new Error(`Status read failed: ${response.status} ${body}`); } console.log(JSON.stringify(JSON.parse(body), null, 2)); return; } } readSendingDomain().catch((error: unknown) => { console.error(error); process.exitCode = 1; }); This probe makes at most 3 requests and sets a 15-second timeout on each request. It performs no DNS write and cannot activate a sender. The previous sender stays selected until application logic explicitly changes it.
Compare providers at the authority boundary
Evaluate Cloudflare DNS, Amazon Route 53, and Resend as real alternatives in the workflow, while keeping the comparison's scope explicit. Cloudflare DNS and Route 53 belong in the zone-management discussion; Resend belongs in the sending-domain discussion. A DNS choice alone does not answer how the application will interpret mail verification. A sending-domain choice alone does not answer who may edit the customer's DNS.
The useful comparison is the integration you would actually ship:
| Option to evaluate | Decision it informs | Boundary to resolve before cutover |
|---|---|---|
| Cloudflare DNS with a mail service | Whether the DNS side fits the zone you intend to manage | Establish write authority and connect record completion to the mail service's verification state. |
| Amazon Route 53 with a mail service | Whether the DNS side fits the zone you intend to manage | Establish write authority and connect record completion to the mail service's verification state. |
| Resend with the customer's DNS workflow | Whether the sending-domain side fits your onboarding | Preserve customer instructions and define how verification status reaches the activation gate. |
There is no basis here to rank those products on measured latency, verification speed, or deliverability. In particular, switching a customer's DNS provider just to reduce the number of integration adapters needs its own justification. An existing provider relationship can matter more than making your backend look uniform.
Infrai is another option when authorized DNS writes and sending-domain verification should sit behind one credential and one REST API, with no SDK required: its self-describing API has a public, unauthenticated discovery surface that supplies request and response schemas plus runnable examples, so adding a capability starts with reading its definition instead of learning another SDK. Its documented idempotency convention is a separate advantage for a workflow that may need retries; check the selected capability's declaration before relying on deduplication.
This REST API can be called over plain HTTP with no SDK to install; its runnable examples cover 10 languages, including TypeScript. That helps keep this onboarding adapter independent of the SDK used for the application's LLM features.
The trade-off is zone authority. A unified API is not a fit for automating records that a customer insists on managing independently; keep their existing DNS workflow and use the sending-domain service for verification instead. That bundle fits the automated branch. It does not eliminate the instructions branch for customers who want to write their own records. The benefit is coordinating the steps in one integration, with the domain status driving the UI; customer authority remains a product decision.
A retry is not a rollback
Retrying the flow and undoing a cutover solve different problems. A retry attempts to complete the intended setup. A rollback changes the application's active sender back to the retained previous value. Design both deliberately, because “try again” is a weak substitute for knowing which hostname the application will use next.
For writes, use the provider's supported idempotency mechanism and keep the logical operation stable across retries. Honor rate-limit guidance and use bounded backoff. After a retry, read status again. The application should reconcile the observed state before changing its active sender, rather than inferring completion from the fact that a request was submitted twice.
Scope rollback carefully.
Preserve the fallback.
Retaining a hostname in a database is useful only if the previous sending setup remains usable. Before activating the proposed hostname, decide how long the previous setup must remain available and who may retire it. Reverting the application-selected sender does not undo mail already sent, and it should not be presented to a customer as restoring the entire DNS zone. Those are different scopes of action.
For SPF, DKIM, and DMARC, use the relevant standards as the reference for authentication semantics. Don't reduce them to a generic “DNS passed” badge. The onboarding gate should express what was checked and which sending domain that evidence belongs to, without suggesting a guarantee about every recipient's handling of future messages.
Finish with evidence the customer can understand
Before enabling the cutover, confirm the proposed hostname, the party authorized to edit its zone, and the retained previous sender. For customer-managed records, make sure the instructions remain accessible after the first visit. For automated records, retain enough application state to reconcile a retried operation. In both cases, request verification and read the sending-domain status back before switching the active sender.
Then exercise the application rollback decision while the previous setup is still available. Define who can trigger that decision and what the UI will show afterward. Stop retries at a deliberate boundary and leave the customer with a concrete next action, such as completing the record instructions or waiting for another status check.
Ship the gate first. A single onboarding step is useful when it reduces coordination work while preserving the customer's control of their zone. The completion screen should follow the evidence.
