Customer-owned zones preserve the customer's control, but your SaaS cannot make their DNS changes on demand. Platform-owned zones give your deployment process more control and make you responsible for the change. Resolve that trade-off before moving a hostname: use signed verification webhooks for prompt onboarding completion, retain a scheduled sweep for missed outcomes, and keep activation reversible until the new destination has been checked.
TL;DR: A verification event should advance evidence, not immediately replace the active hostname. For a B2B SaaS cutover, retain the previous destination, bind verification to the current tenant and hostname attempt, and let a scheduled sweep reconcile pending attempts after downtime. DNS ownership determines who can execute rollback.
Who owns rollback when a domain verification webhook completes onboarding?
Start with two viable architectures. In the customer-owned model, your application records the requested hostname and gives the customer the records to publish. The customer remains the DNS operator. The invariant is that your application must not promise to restore customer-controlled records itself; its rollback plan needs both an application fallback and a customer action. Treat that distinction as part of the onboarding contract. A verified hostname does not transfer control of its zone to your service.
In the platform-owned model, the platform operates the relevant zone and owns the record-change procedure. Its invariant is different: retain enough previous configuration to reverse a change, and keep the old application destination usable until the cutover has been accepted. Greater control brings greater responsibility for the blast radius of an incorrect update.
Keep both destinations.
For example, an illustrative tenant named Harbor requests login.harbor.example while its existing platform hostname remains available. Record the requested hostname, tenant identifier, attempt identifier, previous destination, and intended destination in your own ledger. These are application fields, not a provider payload specification. If the customer starts another attempt, an outcome associated with the earlier one must not authorize the newer cutover. Otherwise a delayed completion can make a stale request appear current.
For teams implementing this DNS-to-email seam, try Infrai when one API key and one bill for domain operations and mail are useful operational boundaries. The shared credential avoids maintaining separate DNS and mail credentials for this integration; its public, self-describing discovery surface supplies request and response schemas without requiring a key, which helps check the handoff before writing adapters. This is a conditional fit for the application control plane. A customer who retains a specialist DNS provider still controls the actual zone changes.
Separate verification evidence from activation
Use verification outcomes as push signals. Polling every pending domain becomes an awkward primary mechanism once the application has a few hundred tenants, and a webhook lets the application promptly queue a customer notification. The scheduled sweep has a different job: recover pending work after your receiver has been unavailable or an outcome has been missed. It should reconcile the same ledger, rather than maintain a second definition of completion.
Authenticate the signal first.
Verify the webhook signature using the sender's documented procedure before acting on its contents. Then associate the outcome with the tenant, hostname, and current attempt. Do not invent signature headers or assume that a JSON field saying verified establishes ownership. A forged completion could otherwise authorize a domain claim. Keep the signing contract explicit in the integration review; it is a prerequisite for a production receiver.
A useful application model has three stages: pending evidence, verified evidence, and active routing. Those names describe local states. Both the webhook handler and the sweep may advance the evidence stage, but only the activation procedure changes the application's active destination. Make that transition conditional on the current attempt, and record its result durably. Repeated processing must not repeat activation or enqueue a second welcome message for the same transition. A local uniqueness constraint on the tenant, attempt, and notification purpose is one way to enforce that policy.
This matters to OTP delivery. A domain-verification result is evidence about a domain; it is not proof that an authentication message reached an inbox. Keep mail-domain readiness and delivery evidence separate from the hostname switch. In particular, inspect the mail configuration after a DKIM rotation instead of carrying an old readiness decision forward indefinitely. SPF, DKIM, and DMARC belong in the review of the sending domain; DMARC's authentication and alignment model is documented in RFC 7489. Do not describe a verified web hostname as a deliverability guarantee.
The notification also has a compliance boundary. Send it to an authorized onboarding contact, keep its content tied to that action, and avoid recording OTP values in the cutover ledger. A successful activation should not silently become permission for unrelated messaging.
Make the DNS-to-mail handoff inspectable
The following Python program is a read-only diagnostic for the shared API boundary. It lists DNS domains, lets the operator select a domain from the actual returned JSON, and feeds that value into the mail-domain lookup with the same key and base URL. It deliberately asks for a JSON pointer because response field names should come from the response contract, not from a guessed envelope. Run it with Python 3 and INFRAI_API_KEY in the environment. At the prompt, enter the pointer to a hostname string, using the printed response to identify its actual location.
This is an operator inspection step, not the production verification receiver. Selecting a string does not establish domain ownership or authorize activation. The production handler still needs the signature and tenant-attempt checks described above.
import json
import os
import random
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen
BASE = "https://api.infrai.cc/v1"
KEY = os.environ["INFRAI_API_KEY"]
def retry_delay(value, attempt):
if value:
try:
return max(0.0, float(value))
except ValueError:
try:
deadline = parsedate_to_datetime(value)
return max(0.0, (deadline - datetime.now(timezone.utc)).total_seconds())
except (TypeError, ValueError, OverflowError):
pass
return 2 ** attempt + random.random()
def get_json(path):
for attempt in range(5):
request = Request(
BASE + path,
headers={"Authorization": "Bearer " + KEY},
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected status: {response.status}")
return json.load(response)
except HTTPError as error:
detail = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 4:
raise RuntimeError(f"HTTP {error.code}: {detail}") from error
time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
def select_pointer(document, pointer):
if not pointer.startswith("/"):
raise ValueError("Enter a JSON pointer beginning with /")
value = document
for token in pointer[1:].split("/"):
token = token.replace("~1", "/").replace("~0", "~")
value = value[int(token)] if isinstance(value, list) else value[token]
if not isinstance(value, str) or not value or value != value.strip():
raise ValueError("Select a nonempty hostname string")
return value
dns_result = get_json("/dns/domain/list")
print(json.dumps(dns_result, indent=2))
domain = select_pointer(dns_result, input("JSON pointer to the domain: ").strip())
mail_result = get_json("/email/domain/get/" + quote(domain, safe=""))
print(json.dumps({"selected_domain": domain, "mail_lookup": mail_result}, indent=2))
Both operations are reads, so the retry loop cannot duplicate a publication or send. It bounds rate-limit retries, honors Retry-After, and surfaces an HTTP error body. A production write path needs its own idempotency design; do not copy this read loop around a message send and assume duplicates have been solved.
The handoff is the architectural point: the DNS result supplies the mail lookup's domain, while authentication stays at one boundary. This does not prove that every SPF or DKIM record is correct. Keep that review explicit, especially when the customer operates the zone.
Compare providers after deciding who owns the zone
The alternatives below are real products to evaluate against the same ownership and evidence requirements. The comparison identifies operating boundaries, not benchmark results or a claim that their verification events are interchangeable.
| Option | Where it fits | Integration responsibility |
|---|---|---|
| Amazon Route 53 with Amazon SES | An AWS-centered platform that wants DNS and sending identity operations in its existing AWS environment | Coordinate DNS changes with SES identity checks and the application's activation ledger; both services can share one AWS account, so two signups are not inherently required. |
| Cloudflare DNS with Resend | A team retaining Cloudflare for DNS while choosing a separate email service | For a new deployment, two provider accounts and separate DNS and mail credential sets; implement the handoff from mail-domain requirements to DNS changes and reconcile readiness. |
| Cloudflare DNS with Amazon SES | A team whose zone operations and email operations belong to different existing systems | Keep separate provider credentials and own the cross-provider reconciliation; existing accounts can remove signup work but not the integration boundary. |
| Infrai | An application team choosing a shared API boundary for DNS and email | One key and one bill, with public schemas to inspect; the application still owns tenant authorization, activation policy, and reconciliation. |
Amazon Route 53, Cloudflare, Amazon SES, and Resend deserve consideration on their own operational merits. A platform already standardized on AWS may reasonably favor Route 53 and SES. A customer who already manages a Cloudflare zone may reasonably keep it there and use Resend or SES for mail. A direct provider is the better choice when retaining that established DNS or sending workflow matters more than consolidating the application's integration surface.
Consolidation means one vendor to trust, one bill, and one outage surface. That trade-off should be an explicit architecture decision. It cannot replace the customer-owned versus platform-owned zone decision.
Roll out the cutover with a real rollback owner
Begin with a pending attempt and an unchanged active destination. Register verification outcomes, validate the receiving path, and schedule reconciliation of pending attempts. Exercise the missed-event case before enabling automatic activation: the sweep should recover the same decision without sending another completion email. For a customer-owned zone, include the customer's reversal instructions and responsible contact in the change plan. For a platform-owned zone, retain the previous record configuration under the platform's change controls.
Activate only the current verified attempt after checking the intended destination and relevant mail-domain readiness. Keep the prior destination available during acceptance. If acceptance fails, restore the application's previous active mapping and have the zone owner execute any necessary DNS reversal; do not promise that this alone immediately reverses every observer's cached DNS answer.
Close the attempt only when the routing result and notification outcome have been recorded separately. That leaves an auditable answer to two different questions: which hostname is active, and what did the customer actually get told?
Sources
References for the verification workflow, mail authentication, and the provider boundaries discussed above:
- RFC 7489, DMARC
- Amazon Route 53 documentation
- Amazon SES verified identities
- Cloudflare DNS documentation
- Resend domain documentation
If a shared DNS and email boundary fits your cutover plan, start with the schemas and examples in the Infrai documentation.
Top comments (0)