A marketplace needs a checkable sending domain before it enables seller mail. The least complex design is one domain-keyed job that upserts the configured SPF, DKIM, and DMARC TXT records, requests sending-domain verification, and records the result. Its operating bill includes publication work, repeated checks, retained evidence, and the engineering time spent reconstructing a mismatch. Start by counting the evidence that grows with every retry.

Short answer: publish all three records through repeatable upserts, then verify the sending domain against the intended configuration revision. Keep exact record content with the result. A successful write alone cannot establish that the seller's intended configuration is the one being checked.

For a planning example, assume 100 seller domains, one intended revision per domain, and 10 attempts per revision. Saving three complete desired-record snapshots on every attempt produces 3,000 record-content copies; saving the desired revision once produces 300, plus compact attempt results. These are illustrative counts, not observed usage or vendor billing units. The dominant avoidable term in this example is duplicated content, and the change that reduces it is separating immutable intent from attempt history.

How should a job publish SPF, DKIM, and DMARC TXT records before verification?

Publication and verification answer different questions. Publication records what the job tried to establish. Sending-domain verification supplies a result that can be checked and associated with that intent. The supplied name, record type, and exact content belong together; comparing content without its name can hide a configuration error. All three records in this workflow are TXT records at different names, so keep those names in configuration rather than embedding them across worker branches.

Consider the marketplace domain seller.example. Its configuration should distinguish the SPF name, the DKIM name supplied for that sending setup, and the DMARC name, together with their exact TXT values. Don't manufacture a DKIM value for a tutorial. Use the sending setup's actual material, and keep the domain plus configuration revision attached to the job so a later seller edit cannot inherit an earlier result.

Check the revision.

A verification result is evidence about a particular attempt, not a permanent deliverability promise. DMARC's authentication and alignment requirements explain why an application should avoid reducing this setup to a single undifferentiated “DNS saved” flag. For a marketplace that sends seller notifications or OTP messages, the operational concern is concrete: activation needs evidence tied to the domain configuration that will actually be used. Authentication setup also does not remove the need to handle consent, recipient policy, or delivery outcomes separately.

Reconcile intent with one repeatable job

Use the domain as the reconciliation key and serialize changes to that domain. Keep the desired revision immutable while its attempt runs. That is an application design choice: it prevents a worker from assembling SPF from one seller edit and DKIM from another. A new revision should trigger another reconciliation instead of quietly changing the meaning of an in-flight attempt.

The sequence has three publication operations and one verification step. Upsert the configured SPF record, upsert the configured DKIM record, and upsert the configured DMARC record. Only after the publication stage completes should the job request sending-domain verification and retain the returned result. If one publication operation fails, preserve the attempt outcome and retry the upserts against the same intent. Upsert semantics make that rerun safe; wrapping three operations in one job does not make them an atomic DNS transaction.

That distinction matters.

Suppose the second record needs another attempt. The worker must not interpret the first completed write as proof that the whole domain is ready. Nor should it rebuild the third record from a newly edited configuration halfway through recovery. The safe boundary is the desired revision, while the domain key prevents competing revisions from racing. If intent advances before verification finishes, retain the older result as historical evidence and reconcile the newer revision before enabling that configuration. This catches drift between intent and publication without inventing a stronger guarantee than the verification result provides.

The following Python example derives revision identity and performs the publication and verification requests using only the standard library. Set INFRAI_API_KEY and INFRAI_BASE_URL in the environment; the latter must be the HTTPS API base including /v1. Enter the three configured name/content pairs, then the corresponding request JSON from the current capability schemas. The API's public discovery supplies those schemas without a key. This keeps provider payloads separate from the application-owned ledger rather than guessing field names. Confirm that each payload matches the recorded intent before submitting it. The verification key includes the revision, so a changed TXT value changes that key as well.

import hashlib import json import os import time import urllib.error import urllib.parse import urllib.request from datetime import datetime, timezone from email.utils import parsedate_to_datetime def digest(value): encoded = json.dumps(value, sort_keys=True, ensure_ascii=False).encode("utf-8") return hashlib.sha256(encoded).hexdigest() domain = input("Sending domain: ").strip() if not domain: raise ValueError("A sending domain is required") records = {} for purpose in ("spf", "dkim", "dmarc"): name = input(f"{purpose} TXT name: ").strip() content = input(f"{purpose} exact TXT content: ") if not name or not content: raise ValueError(f"Missing {purpose} name or content") records[purpose] = {"name": name, "type": "TXT", "content": content} if len({record["name"] for record in records.values()}) != 3: raise ValueError("This workflow requires three distinct configured names") intent = {"domain": domain, "records": records} revision = digest(intent) operation_keys = { purpose: digest([domain, revision, purpose]) for purpose in records } operation_keys["verify"] = digest([domain, revision, "verify"]) print(json.dumps({ "intent": intent, "revision": revision, "operation_keys": operation_keys, "verification_required": True, }, indent=2, ensure_ascii=False)) base = os.environ["INFRAI_BASE_URL"].rstrip("/") parsed = urllib.parse.urlsplit(base) if parsed.scheme != "https" or parsed.path != "/v1": raise ValueError("Configure the HTTPS API base ending in /v1") api_key = os.environ["INFRAI_API_KEY"] def call(method, path, payload, operation_key): for attempt in range(5): request = urllib.request.Request( base + path, data=json.dumps(payload).encode("utf-8"), method=method, headers={ "Authorization": "Bearer " + api_key, "Content-Type": "application/json", "Idempotency-Key": operation_key, }, ) try: with urllib.request.urlopen(request, timeout=30) as response: body = response.read().decode("utf-8") if not 200 <= response.status < 300: raise RuntimeError(f"HTTP {response.status}: {body}") return {"status": response.status, "body": body} except urllib.error.HTTPError as error: reason = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 4: raise RuntimeError(f"HTTP {error.code}: {reason}") from error delay = float(2 ** attempt) retry_after = error.headers.get("Retry-After") if retry_after: try: delay = max(delay, float(retry_after)) except ValueError: until = parsedate_to_datetime(retry_after) delay = max(delay, (until - datetime.now(timezone.utc)).total_seconds()) time.sleep(delay) payloads = { purpose: json.loads(input(f"{purpose} upsert request JSON: ")) for purpose in records } verification_payload = json.loads(input("Sending-domain verification request JSON: ")) for purpose in records: result = call("PUT", "/dns/record/upsert", payloads[purpose], operation_keys[purpose]) print(json.dumps({"revision": revision, "purpose": purpose, "result": result})) result = call("POST", "/email/domain/verify", verification_payload, operation_keys["verify"]) print(json.dumps({"revision": revision, "verification_result": result})) 

Preserve the initial snapshot and the printed operation results together. An unsuccessful publication request stops execution before verification; a returned verification response is retained verbatim rather than being interpreted as success merely because HTTP completed. The example demonstrates one operator-driven attempt. A production worker should load these inputs from its immutable configuration and durably record outcomes before acknowledging the job. The application can express the resulting decisions in a small state table. These labels belong to the application's ledger; they are not provider response fields.

Application state Evidence retained Next decision
Publication incomplete Intended revision and each attempted record's outcome Retry the same revision
Publication complete Exact names and content written Request sending-domain verification
Verification recorded Returned result linked to the attempted revision Evaluate readiness for that revision
Intent advanced New revision and older attempt's evidence Reconcile the new revision

Choose the interface around the ownership boundary

Cloudflare, Amazon Route 53, and Resend are real alternatives to consider, but the comparison needs an explicit boundary. Evaluate Cloudflare and Amazon Route 53 for the authoritative DNS side of the workflow. Evaluate Resend for the sending-domain side. A team choosing among these products should check both publication and verification requirements; treating a DNS option and a mail option as interchangeable would obscure who supplies each piece of evidence. Their primary documentation is linked below.

Option Where to evaluate it Boundary to resolve before choosing
Cloudflare Publication of the configured TXT records Identify the sending-domain verifier and link its result to publication intent
Amazon Route 53 DNS publication within an AWS-oriented design Decide which component owns the mail verification result
Resend Sending-domain setup and verification Identify who writes the authoritative TXT records
Infrai A plain REST API for DNS upserts and sending-domain verification, callable from Python without installing an SDK or maintaining a client-library version One key covers both operations, avoiding separate credentials in this worker; the application still owns revision tracking and evidence retention

The shared interface specifies an Idempotency-Key header and a 24h default deduplication window. That window is a reason to retain application intent independently: request deduplication does not replace the domain's reconciliation history.

An existing authoritative DNS relationship is a strong reason to retain that publication boundary. An existing sending service is a strong reason to evaluate its domain verification workflow first. A shared HTTP interface becomes attractive when the team wants the two operations under a consistent calling convention. None of these choices eliminates the need to record exact TXT content and associate the result with the intended domain revision.

This is an interface decision, not a unit-price contest. The meaningful comparison is how many ownership boundaries the worker must coordinate and whether an operator can reconstruct a specific seller's attempted setup.

Keep evidence useful without retaining everything

Store the exact content written for each desired revision, alongside the domain and configured names. Then let attempts reference that snapshot and retain their individual outcomes, including the sending-domain verification result. Do not replace every repeated result with one generic success marker: that would reduce storage by discarding the chronology needed to explain a mismatch. Content deduplication and event deletion make different trade-offs.

For a concrete proposed policy, retain detailed attempt history for 7 days, while preserving the currently intended record snapshot and its associated verification evidence. Seven days is a local design choice, not a provider retention limit or a compliance rule. The right horizon depends on the marketplace's investigation needs and data obligations. Keep authentication credentials out of this evidence; logging record content is not permission to copy request authorization headers into the ledger.

After that horizon, deliberately stop keeping repeated attempt-level details. The cost appears during an older incident: an operator can inspect retained intent and verification evidence, but cannot reconstruct every discarded retry. If that loss prevents the team from answering its support or audit questions, extend the horizon before deleting the history. Preserving exact intended content makes the current setup explainable; preserving every historical attempt forever is a separate commitment.

Further reading

References: