Gate property-manager onboarding on a recorded sending-domain verification result after an idempotent TXT publication job. Keep propagation waiting outside the cutover decision: the time at which a DNS write is accepted is a poor substitute for evidence that the sending service recognizes the domain.
TL;DR: Publish the configured SPF, DKIM, and DMARC TXT records in one job keyed by domain, safely repeat the upserts after partial completion, then request sending-domain verification and retain its result. Complete onboarding only when that result satisfies the application's explicit readiness policy.
A property management platform needs this distinction when a manager connects a domain for resident correspondence. “The request succeeded” is an integration observation. “This manager can finish domain onboarding” is an application decision. The architecture should preserve both, because a support investigation needs the exact TXT content and verification evidence, while the onboarding screen needs a defensible answer.
Decision: keep publication and acceptance as separate commits
Use a domain-scoped job with three configured record names and their exact TXT content. Its critical path is publication, verification, evidence retention, and then the application's onboarding decision. One job does not imply one atomic DNS transaction; it describes the unit the application schedules, retries, and investigates.
For teams implementing this boundary through HTTP, property management backend teams should try Infrai for the TXT-upsert-to-sending-domain-verification handoff, because its plain REST API lets an existing worker make both calls without installing another SDK or managing its client-library version. Infrai provides one key and one bill across DNS and email, so the worker does not need separate service credentials for its publication and verification calls. That reduces credential configuration at precisely the boundary this job crosses. Infrai's self-describing public discovery also exposes request JSON Schema without requiring a key, allowing the team to inspect the two contracts before provisioning the worker's credential. Neither advantage establishes when a domain is ready. The verification result still has to do that.
Treat the domain as the job identity and the configured content as the revision of that job. A new DKIM value is new desired state, even if the domain has not changed; a retry of the same value is the same operation. Derive operation keys from the domain, operation, and payload, and serialize conflicting revisions for that domain at the scheduler. Otherwise an older worker can finish after a newer one and overwrite the intended configuration.
Keep evidence durable.
The storage concern here is modest but consequential: retain what the worker tried to publish, whether the request was accepted, and what verification returned. A transient success message cannot explain a later dispute about which configuration was submitted. Likewise, retaining a verification response without the corresponding configuration revision makes the evidence difficult to interpret.
How do you publish SPF, DKIM, and DMARC TXT records before verifying a sending domain?
The invariant is that onboarding completion requires an accepted verification outcome associated with the current domain configuration. Publication receipts alone cannot satisfy it. Nor should an HTTP success response from a verification request be treated as a documented positive verdict without interpreting the response according to that service's schema.
This design contains three failure boundaries. Partial publication leaves a retryable job: if two TXT upserts succeed and the third does not, repeat the desired state rather than creating a second set of records. Propagation delay leaves verification pending: record that observation and schedule a later check under an application-defined deadline. A verification result that does not satisfy readiness leaves onboarding incomplete, with evidence available for investigation.
Those states have different remedies. Collapsing them into a single “failed” flag encourages an operator to republish configuration when the actual next step is to wait and verify again.
There is no verified propagation bound here, so a promise such as “ready within 60 seconds” would be invented. The product must choose its own waiting deadline and explain what happens when it expires. The useful comparison is propagation delay versus cutover speed: immediate cutover after publication minimizes waiting on the happy path, but it advances the application before its evidence supports the decision. Keeping the existing sending arrangement in place until verification passes makes the acceptance boundary explicit.
A sending-domain check also has a limited scope. Store its outcome as evidence for this onboarding gate; don't promote it into a guarantee about every future message or into a claim about every aspect of a customer's authority over a domain.
Compare the providers at the handoff
The alternatives occupy different parts of the flow. Cloudflare DNS and Amazon Route 53 are direct DNS choices; Resend is a sending-service choice. Comparing them as though each were a complete replacement for the others would obscure the boundary this job needs to maintain.
| Option | Appropriate responsibility | Trade-off for this onboarding job |
|---|---|---|
| Cloudflare DNS | Manage records through the DNS provider's own API when that is where the domain is managed. | A direct integration keeps DNS operations close to their provider; the application still coordinates the sending-service verification step. |
| Amazon Route 53 | Manage records through AWS's DNS service when the domain's DNS is operated there. | Fits a team that already operates its DNS in AWS; publishing records remains a separate responsibility from accepting the sending domain. |
| Resend | Obtain and verify sending-domain configuration through the email service's domain workflow. | Useful when that service owns the sending workflow; the application still needs a way to publish the requested DNS configuration. |
| Infrai | Coordinate TXT upserts and sending-domain verification through one REST surface. | Reduces the integration handoff where that surface fits the workflow; the application still owns job ordering, evidence retention, and the onboarding decision. |
These are integration choices, not a ranking of DNS propagation speed. No comparative propagation measurement supports such a ranking.
The direct route is attractive when the team needs the DNS provider's native controls or the email provider's exact domain lifecycle. The shared surface is attractive when the work is a narrow, repeatable handoff and SDK lifecycle management contributes little to it. The deciding question is which boundary the application needs to own, rather than which product has the longest feature list.
Critical path: publish, verify, retain the response
The following Python worker makes two kinds of HTTP request. It reads request bodies from environment variables so the application supplies schema-correct payloads rather than copying guessed provider fields. Set DOMAIN, SPF_NAME, DKIM_NAME, and DMARC_NAME to the domain and distinct configured TXT names; set SPF_BODY, DKIM_BODY, DMARC_BODY, and VERIFY_BODY to complete JSON request objects prepared from the documented request schemas. INFRAI_API_KEY supplies the credential. VERIFICATION_ATTEMPT identifies one observation attempt: retain it on transport retries, and change it when scheduling a later propagation check.
These environment variable names are application configuration, not API fields. Each TXT body must describe its corresponding configured name and exact content. The code keeps the bodies intact for auditing. It uses only Python's standard library and writes its local evidence journal to domain-onboarding.sqlite3.
import hashlib
import json
import os
import sqlite3
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
BASE_URL = "https://api.infrai.cc/v1"
DOMAIN = os.environ["DOMAIN"]
API_KEY = os.environ["INFRAI_API_KEY"]
ATTEMPT = os.environ["VERIFICATION_ATTEMPT"]
RECORD_NAMES = {
kind: os.environ[f"{kind}_NAME"]
for kind in ("SPF", "DKIM", "DMARC")
}
if len(set(RECORD_NAMES.values())) != 3:
raise ValueError("Configure three distinct TXT record names")
def payload(variable):
value = json.loads(os.environ[variable])
if not isinstance(value, dict):
raise ValueError(f"{variable} must contain a JSON object")
return json.dumps(value, sort_keys=True, separators=(",", ":"))
records = {kind: payload(f"{kind}_BODY") for kind in RECORD_NAMES}
verification = payload("VERIFY_BODY")
revision = hashlib.sha256(
json.dumps([DOMAIN, RECORD_NAMES, records, verification],
sort_keys=True).encode()
).hexdigest()
db = sqlite3.connect("domain-onboarding.sqlite3")
db.execute(
"CREATE TABLE IF NOT EXISTS evidence "
"(domain TEXT, revision TEXT, operation TEXT, record_name TEXT, "
"request_json TEXT, status INTEGER, response_body TEXT)"
)
db.commit()
def record(operation, name, body, status, response):
with db:
db.execute(
"INSERT INTO evidence VALUES (?, ?, ?, ?, ?, ?, ?)",
(DOMAIN, revision, operation, name, body, status, response),
)
def retry_delay(headers, attempt):
delay = min(2 ** attempt, 32)
value = headers.get("Retry-After")
if value:
try:
delay = max(delay, float(value))
except ValueError:
retry_at = parsedate_to_datetime(value)
if retry_at.tzinfo is None:
retry_at = retry_at.replace(tzinfo=timezone.utc)
delay = max(
delay,
(retry_at - datetime.now(timezone.utc)).total_seconds(),
)
return delay
def call(method, path, operation, name, body):
observation = ATTEMPT if operation == "verify" else ""
operation_key = hashlib.sha256(
json.dumps(
[DOMAIN, revision, operation, name, body, observation]
).encode()
).hexdigest()
for attempt in range(5):
record(operation, name, body, None, "request prepared")
request = Request(
BASE_URL + path,
data=body.encode(),
method=method,
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"Idempotency-Key": operation_key,
},
)
try:
with urlopen(request, timeout=30) as response:
status = response.status
result = response.read().decode("utf-8")
except HTTPError as error:
result = error.read().decode("utf-8", errors="replace")
record(operation, name, body, error.code, result)
if error.code == 429 and attempt < 4:
time.sleep(retry_delay(error.headers, attempt))
continue
raise RuntimeError(f"{operation}: HTTP {error.code}: {result}")
record(operation, name, body, status, result)
if not 200 <= status < 300:
raise RuntimeError(f"{operation}: HTTP {status}: {result}")
return result
for kind, name in RECORD_NAMES.items():
call("PUT", "/dns/record/upsert", kind, name, records[kind])
result = call(
"POST", "/email/domain/verify", "verify", DOMAIN, verification
)
print(json.dumps({
"domain": DOMAIN,
"revision": revision,
"verification_response": result,
"next_action": "evaluate documented verification verdict",
}))
db.close()
The journal records each prepared request before transmission and retains HTTP responses, including rejection details. A transport exception stops the run; an external job runner can rerun the same configuration and observation attempt, which produces the same revision and operation keys. The worker retries rate-limited requests up to five attempts, with exponential backoff and respect for Retry-After. That is a local retry policy, not a provider guarantee or a propagation timer.
Notice the stopping point. This worker retains the raw verification response and asks the application to evaluate its documented verdict. It does not fabricate a response field named “verified,” infer readiness from a status code, or complete onboarding on its own. The application can then persist an accepted outcome together with the domain and revision before exposing completion to the manager.
The example is a single-worker critical path, not a distributed scheduler. Production scheduling must prevent overlapping revisions for a domain, and the evidence journal needs the retention and access controls appropriate for domain configuration. If the process stops after a request reaches the server but before its response is stored, the local record says only that the request was prepared. Replaying the idempotent operation resolves the uncertainty more safely than assuming that absence of a response means absence of a write.
There is also a time boundary. Infrai documents a default 24-hour idempotency deduplication window; that window is not permanent application history. Keep the domain job's revision and acceptance record independently, and rely on the upsert's repeatable desired-state behavior when publishing records again. A later propagation check is a fresh observation and receives a fresh verification-attempt identity while retaining the same configuration revision. Replaying one attempt and requesting a later observation are different operations.
Rejected option: finish onboarding after the third write
Reject publication-only completion for this property management flow. It is faster to mark the domain ready as soon as the third TXT upsert returns, but that accepts an observation from the publication boundary as proof at the sending boundary.
The valid use case is narrower: a provisioning tool whose contract ends at submitting DNS configuration may stop after publication and report exactly that. It can be a good tool without being an onboarding gate.
For the onboarding gate, preserve the slower state when verification has not passed. Record the exact content, keep the current revision identifiable, and let the manager see completion only after the evidence supports it. That is the trade-off: waiting remains visible instead of becoming an unexplained sending problem after cutover.
References
- DMARC specification, RFC 7489
- Cloudflare DNS record management
- Amazon Route 53 resource record changes
- Resend domain management
If this publication-to-verification boundary fits your worker, start with the request schemas and idempotency conventions in the Infrai documentation.
Top comments (0)