Use one tenant record manifest to generate customer-facing DNS instructions and the exact values your verifier expects. Treat the resulting handoff as a revision of that manifest, so a change to the required records also changes what the customer receives.
TL;DR: Generate the instructions from the records you will actually check. For a B2B SaaS product that automatically assigns tenant subdomains, this removes drift between the handoff and verification logic. It does not prove that the customer's DNS administrator published those records. Publication needs separate evidence.
A hostname can route to the application while its mail authentication setup is still incomplete. That distinction matters when an onboarding flow also sends invitations or OTP messages: an application URL working is not evidence about a sending domain.
How should customer DNS instructions track a changing record set?
The decision here is about evidence provenance: which revision produced the instructions, and which revision was used to judge the published records? Keep that question attached to the tenant throughout onboarding. A generic “DNS configured” flag loses too much information.
The invariants are small. Every requirement has an exact name, type, and content string. The customer document and the expected verification input come from the same immutable manifest. Observed records remain separate from desired records. A readiness decision refers to the revision it checked.
Preserve the strings.
For example, changing a record's target in the application while leaving an old setup email in circulation creates two competing instructions. Regenerating a document fixes the source of future handoffs; it cannot recall a forwarded attachment. Put the tenant and revision in the document so the administrator can identify an obsolete copy. The person editing DNS may never have logged into your application.
For this design, the application provisions names beneath its own SaaS zone automatically. Customer-managed sending domains are a separate administrative boundary. Do not ask a customer to edit your zone, and do not let a successful change in your zone stand in for their sending-domain checks. Keeping those boundaries explicit also limits what an onboarding worker should be permitted to change.
2. Compare the seam between DNS and mail
Choose around the handoff you need to maintain. A common API does not remove the need for a manifest, and separate providers do not prevent you from building one.
| Option | What it contributes to this workflow | Boundary you still own |
|---|---|---|
| Amazon Route 53 with Amazon SES | DNS and email are separate AWS services, suitable when the application already operates there. | Map the services' separate interfaces and permissions into one tenant revision and handoff. An AWS account can cover both; two signups are not inherently required. |
| Cloudflare with Resend | Separates DNS administration from the email service, useful when those responsibilities belong to different teams. | For a new deployment, plan for two provider accounts and two credential sets, plus the code that translates mail requirements into DNS changes and verification evidence. |
| Infrai | Plain REST requests cover DNS and email with the same API key and base URL; no SDK or client-library version is required. Public discovery supplies request and response schemas for building the adapter. | Keep tenant authorization, exact record rendering, and readiness policy in the application. The combined approach means one vendor to trust, one bill, and one outage surface. |
These are integration choices, not deliverability rankings. There is no comparative delivery measurement here. An email provider's domain status and your application's hostname status answer different questions; neither should silently overwrite the other.
The trade-off is control versus integration work. A shared provider is not a good fit when policy requires separate DNS and mail credentials or independently selected operators. Choose Route 53 with SES for an existing AWS operating model, or Cloudflare with Resend when separate DNS and mail ownership is the requirement. This is a limitation of the combined operating model, not a claim about delivery quality.
The separate-provider stack makes the glue particularly visible: fetch the sending-domain requirements, preserve their exact strings, associate them with the tenant, render instructions, and reconcile the resulting records. With a shared API, the credential boundary is smaller. The evidence boundary remains.
3. Build the manifest and the customer handoff together
Start with a local executable contract before wiring in provider adapters. The following Python program uses three synthetic records for two tenants. The reserved example names and target values are fixtures, not production DNS instructions or an email provider's requirements.
Save this block as tenant_records.py and run it with Python 3. It prints a document that can be forwarded to a DNS administrator, then checks a deliberately stale observation. It makes no network requests.
import json
MANIFEST = {
"tenant": "cedar",
"revision": 7,
"records": [
{
"name": "cedar.saas.example",
"type": "CNAME",
"content": "edge.saas.example",
},
{
"name": "_proof.mail.cedar.example",
"type": "TXT",
"content": "tenant=cedar; revision=7",
},
],
}
OTHER_TENANT = {
"tenant": "maple",
"revision": 2,
"records": [
{
"name": "maple.saas.example",
"type": "CNAME",
"content": "edge.saas.example",
}
],
}
def record_key(record):
return tuple(record[field] for field in ("name", "type", "content"))
def expected_records(manifest):
return frozenset(record_key(record) for record in manifest["records"])
def render(manifest):
lines = [
f'Tenant: {manifest["tenant"]}',
f'Record revision: {manifest["revision"]}',
"Publish these exact record values:",
]
for record in manifest["records"]:
lines.append(json.dumps(record, ensure_ascii=True, sort_keys=True))
return "\n".join(lines)
def missing_records(manifest, observed):
actual = {record_key(record) for record in observed}
return sorted(expected_records(manifest) - actual)
if __name__ == "__main__":
print(render(MANIFEST))
observed = [
dict(MANIFEST["records"][0]),
{
"name": "_proof.mail.cedar.example",
"type": "TXT",
"content": "tenant=cedar; revision=6",
},
dict(OTHER_TENANT["records"][0]),
]
missing = missing_records(MANIFEST, observed)
assert len(missing) == 1
assert missing[0][2] == "tenant=cedar; revision=7"
assert not missing_records(MANIFEST, MANIFEST["records"])
print(json.dumps({"missing": missing}, indent=2))
The old revision must fail.
Don't guess readiness. A record belonging to Maple must not satisfy Cedar's requirement. Those assertions are the acceptance criteria for this step, rather than an assertion that DNS has propagated.
The verifier uses subset matching because unrelated records can exist in the same zone. Requiring the whole zone to equal the tenant manifest would make unrelated additions look like tenant failures. Conversely, checking only the name would accept the stale TXT value in this example.
This example compares already normalized observations. A production DNS adapter must handle DNS representation rules before producing that shape; it must not change the literal content shown in the customer document. Do not apply a blanket lowercase transformation to TXT content. The fixture's proof record is application data, not SPF, DKIM, or DMARC.
For real mail setup, populate the manifest from the sending service's actual requirements. DMARC's published policy is a separate concern from this application proof token. Keep authentication instructions exact, and avoid treating correct DNS as a promise that invitations will reach an inbox.
4. Carry DNS evidence into the mail-service check
The next step demonstrates the critical API handoff without assuming an undocumented response field. It reads a DNS record listing, finds an exact tenant-domain string in that output, and uses that returned string to request the corresponding email-domain information. Both requests use the same credentials.
Configure API_BASE_URL to the service's documented HTTPS API base, including its version segment, and set INFRAI_API_KEY and TENANT_MAIL_DOMAIN in the environment. Save the block as check_handoff.py and run it with Python 3. Only run this read example with credentials authorized for the relevant tenant data.
import email.utils
import json
import os
import time
import urllib.error
import urllib.parse
import urllib.request
from datetime import datetime, timezone
BASE = os.environ["API_BASE_URL"].rstrip("/")
KEY = os.environ["INFRAI_API_KEY"]
DOMAIN = os.environ["TENANT_MAIL_DOMAIN"]
if not BASE.startswith("https://"):
raise ValueError("API_BASE_URL must use HTTPS")
def retry_delay(header, attempt):
fallback = float(2 ** attempt)
if not header:
return fallback
try:
return max(fallback, float(header))
except ValueError:
until = email.utils.parsedate_to_datetime(header)
return max(
fallback,
(until - datetime.now(timezone.utc)).total_seconds(),
)
def get_json(path):
for attempt in range(4):
request = urllib.request.Request(
BASE + path,
headers={"Authorization": f"Bearer {KEY}"},
method="GET",
)
try:
with urllib.request.urlopen(request, timeout=20) as response:
return json.load(response)
except urllib.error.HTTPError as error:
if error.code == 429 and attempt < 3:
time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
continue
reason = error.read().decode("utf-8", errors="replace")
raise RuntimeError(f"HTTP {error.code}: {reason}") from error
raise RuntimeError("Retry budget exhausted")
def strings(value):
if isinstance(value, str):
yield value
elif isinstance(value, dict):
for child in value.values():
yield from strings(child)
elif isinstance(value, list):
for child in value:
yield from strings(child)
dns_evidence = get_json("/dns/record/list")
matched_domain = next(
(value for value in strings(dns_evidence) if value == DOMAIN),
None,
)
if matched_domain is None:
raise SystemExit("No exact domain value found; inspect the DNS response schema.")
mail_evidence = get_json(
"/email/domain/get/" + urllib.parse.quote(matched_domain, safe="")
)
print(json.dumps({
"domain": matched_domain,
"dns_evidence": dns_evidence,
"mail_evidence": mail_evidence,
}, indent=2))
A successful read isn't approval.
This is a read-only evidence handoff. The exact-string search deliberately avoids inventing a field name. It is not a record verifier: a domain string appearing somewhere in a response does not establish its role, ownership, or publication status. If the list does not contain that exact string, the program stops. For a production adapter, use the published schemas to select the domain and record fields explicitly and handle any documented pagination or scope requirements.
Success at this step means both responses were retrieved and associated with the same selected domain. It does not mean “activate the tenant.” Feed schema-mapped record observations into the manifest comparison, and interpret the mail response using its documented schema before deciding readiness. Keep the evidence internal; an administrator needs the approved record instructions, not an export of every record the credential can read.
The code bounds rate-limit retries to 4 attempts, honors Retry-After, and surfaces unsuccessful HTTP responses. It performs no writes. A provisioning worker that creates or updates records needs its own idempotent write policy; a timed-out request must not become an excuse to apply an untracked second change.
5. Reject hand-maintained record values, retain human guidance
The rejected option is a prose template containing a second copy of required record values. It is attractive because support staff can edit it quickly. The first requirement change makes that second copy a liability unless someone remembers to update both the verifier and every relevant document.
Human-written guidance still has a valid role. Explain who should receive the handoff, which zone they control, and how they can report a blocked change. Generate the names and content strings inside that guidance.
Keep the old revision.
Consider the Cedar fixture as an onboarding acceptance exercise. Revision 6 asks the customer's DNS administrator to publish one proof string, and revision 7 asks for another. The administrator receives the old attachment after the application has already generated the new one, publishes exactly what the attachment says, and reports that setup is complete. Nothing in this exercise requires a misspelled hostname or a careless administrator: both documents can be internally correct for their own revision. The application should compare the observation with revision 7, identify the stale value, and regenerate the current handoff rather than asking support to rewrite the record in an email. Meanwhile, Maple's working hostname must remain irrelevant to Cedar's readiness, even if both tenants share the same application target. Preserve the association between the tenant, manifest, generated document, and verification result under the application's access and retention policy. If the product later changes the required target again, repeat the same process with a new revision instead of editing the old evidence. This costs more bookkeeping than a mutable setup page, but it gives the administrator and support team a concrete question to resolve: which revision did you publish?
The acceptance rule is precise: the customer instructions and expected checks must come from the same tenant revision, while readiness requires independently observed evidence for that revision. This removes a preventable source of documentation drift and leaves publication, authorization, and mail delivery as explicit boundaries.
References
- RFC 7489, Domain-based Message Authentication, Reporting, and Conformance: https://datatracker.ietf.org/doc/html/rfc7489
- Amazon Route 53 Developer Guide: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html
- Amazon SES Developer Guide: https://docs.aws.amazon.com/ses/latest/dg/Welcome.html
- Cloudflare DNS documentation: https://developers.cloudflare.com/dns/
- Resend domain documentation: https://resend.com/docs/dashboard/domains/introduction
Top comments (0)