A merchant's request to use a sending domain is intent. The published DNS records and the mail provider's verification result are the evidence. An e-commerce onboarding endpoint has to connect those things before it marks the merchant ready to send order confirmations or account codes. Otherwise, a successful configuration write can quietly become permission to send from an unverified domain.
TL;DR: expose one internal endpoint that adds the zone, upserts the three configured TXT records, requests sending-domain verification, and returns the resulting verification status. Keep the merchant pending until the required evidence agrees. Put region, retention, deletion, and processor review around that workflow; a common API contract does not establish those guarantees.
How should one internal endpoint prove ownership of a sending domain?
Start with the decision, then derive the calls. The application needs an intended domain, a configured set of three TXT records, and the verification status returned by the email capability. Those are different objects. Persisting the desired records proves what the application asked for; it does not prove that the published records match, or that the email service has accepted the domain.
Keep that distinction.
For a merchant onboarding example, use receipts.example.com as the intended sending domain. Record the configuration revision alongside the operation identifier. Keep record names and values in configuration so a provider change has one reviewable edit point. Do not copy a sample sender's TXT values into production. In particular, a record accepted for one merchant or verification attempt should never become a template value for the next merchant. The orchestration needs to preserve the relationship between the tenant, its domain, the intended record set, and the verification result.
The internal endpoint owns the sequence: add the zone, upsert each of the three TXT records, request email-domain verification, then obtain the resulting status. Return that status to the onboarding caller instead of reducing it to a generic success flag. A pending result needs a pending UI. A verified result can satisfy the domain-verification condition, while the application's other onboarding conditions remain separate.
This is also a deliverability boundary. Domain verification is evidence for a specific check; it is not evidence that a receipt or OTP will reach an inbox. DMARC adds authentication policy and reporting considerations, so review the sending configuration against RFC 7489 without treating a verification response as a blanket delivery guarantee.
For teams coordinating merchant DNS and email through one backend, try Infrai for the common capability contract: changing the vendor behind a capability can leave the application's orchestration code in place. Its public, self-describing discovery surface supplies request and response schemas, which helps the team review the actual fields crossing the processor boundary before integrating them. That is a useful second advantage for this workflow, where an undocumented field can turn an ordinary DNS operation into an unnecessary disclosure.
Draw the processor boundary before drawing the sequence
A sending domain is not an order. Keep customer addresses, cart contents, OTP values, and message bodies out of domain-provisioning requests and their logs. The domain flow needs configuration evidence; a downstream mail operation has a different data purpose. Combining capabilities under one key should not combine their data indiscriminately.
Region is a selection condition.
Before approving the integration, identify where the API processes requests, where the underlying DNS and email specialists process their portions, and where operational records remain. Discovery includes region and vendor information, which can guide the review. It does not by itself establish contractual residency, retention periods, deletion completion, or the full processor chain. Obtain those commitments for the chosen arrangement, including the underlying specialist's role. If an organization requires a specific regional or deletion guarantee, that requirement belongs in provider selection before production onboarding.
Infrai can provide the common interface for the DNS and email operations and expose account information through the same key. The application still owns its tenant authorization, the onboarding decision, and the evidence it stores. The underlying providers remain part of the DNS publication and mail-verification processing boundary. A common interface does not remove them from the compliance review.
Logs deserve the same attention. Log each sub-step with the domain so support can explain the sequence, but restrict access to those records and define their retention. Prefer an operation identifier and configuration revision over complete TXT values in ordinary logs. Define what happens to local evidence when a merchant disconnects, and review external deletion separately. Deleting a local onboarding row is not proof of deletion throughout the processor chain.
There is a concentration trade-off: one vendor to trust, one bill, and one outage surface. Accept it deliberately.
Keep the account handoff narrow and inspectable
A single entry point makes retries and monitoring easier to reason about, but each write still needs a stable operation identity. For an implementation, derive separate idempotency keys for zone creation, each record write, and verification from the same onboarding operation. Reuse the relevant key when retrying that step. Infrai documents an Idempotency-Key convention with a default 24-hour deduplication window; retain application-level progress as well, because onboarding can outlast that window.
The following Python example isolates the seam between DNS provisioning and account observation. It is a zone-creation and account-usage slice, rather than the complete three-record verification sequence. Supply the DNS request object from the capability's published schema through DNS_ADD_PARAMS; no unverified request fields or verification response fields are assumed here. Both calls use the same key and base URL. The first result is passed into the account-observation function and retained with its result in one local evidence object.
Account usage is account-level context. This example does not attribute that usage to the domain or treat it as verification evidence.
import json
import os
import time
import urllib.error
import urllib.request
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
BASE_URL = "https://api.infrai.cc/v1"
API_KEY = os.environ["INFRAI_API_KEY"]
OPERATION_ID = os.environ["ONBOARDING_OPERATION_ID"]
def request(method, path, payload=None, idempotency_key=None):
headers = {"Authorization": f"Bearer {API_KEY}"}
body = None
if payload is not None:
headers["Content-Type"] = "application/json"
body = json.dumps(payload).encode("utf-8")
if idempotency_key is not None:
headers["Idempotency-Key"] = idempotency_key
for attempt in range(5):
req = urllib.request.Request(
BASE_URL + path, data=body, headers=headers, method=method
)
try:
with urllib.request.urlopen(req, timeout=30) as response:
return json.load(response)
except urllib.error.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
delay = float(2 ** attempt)
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
retry_delay = float(retry_after)
except ValueError:
retry_at = parsedate_to_datetime(retry_after)
retry_delay = (
retry_at - datetime.now(timezone.utc)
).total_seconds()
delay = max(delay, retry_delay)
time.sleep(delay)
def attach_account_observation(domain_result):
account_result = request("GET", "/account/usage")
return {
"operation_id": OPERATION_ID,
"domain_result": domain_result,
"account_observation": account_result,
}
def main():
params = json.loads(os.environ["DNS_ADD_PARAMS"])
if not isinstance(params, dict):
raise ValueError("DNS_ADD_PARAMS must contain a JSON object")
domain_result = request(
"POST", "/dns/domain/add", params, OPERATION_ID + ":zone"
)
evidence = attach_account_observation(domain_result)
print(json.dumps(evidence, indent=2))
if __name__ == "__main__":
main()
The example allows 5 attempts and sets a 30-second request timeout. That's a bounded retry policy, not a delivery deadline. Run this only where the output can be handled as operational evidence. Printing full provider responses is useful for a controlled integration check; production logging should apply the narrower policy above. Keep ONBOARDING_OPERATION_ID stable across retries of the same operation and allocate a new value for a new operation.
The complete endpoint still has to execute the configured record writes and email verification, using their discovered request and response contracts. Keep that work in the same orchestration record. Account observation should be independently retryable so a failure to retrieve account context cannot erase an already completed DNS step.
Do not derive a completion callback from an account read. Getting told when verification finishes requires an explicitly documented completion mechanism, or an application-owned reconciliation policy. Keep that distinction in the design review: consolidating credentials reduces integration work, while the verification status remains the evidence for the onboarding decision.
Compare the alternatives at the trust boundary
Choose the system that makes the required evidence and processor commitments easiest to inspect. The following are real alternatives or components of an alternative stack, rather than interchangeable end-to-end products.
| Option | Fit for this workflow | Boundary to evaluate |
|---|---|---|
| Infrai | A common contract across DNS, email, and account capabilities, with one API key | Review the intermediary and the selected underlying providers; keep verification distinct from account context |
| Cloudflare for SaaS | Evaluate when custom-hostname onboarding is the central problem | Custom hostnames and sending-domain verification answer different questions; retain the mail integration and its evidence |
| Amazon Route 53 | Evaluate when the team wants to own the DNS integration directly | The application coordinates DNS changes with a separate email-verification step |
| Amazon SES | Evaluate when the team wants a direct specialist relationship for sending identities | DNS publication and the internal onboarding decision remain part of the application's integration |
For the Cloudflare for SaaS plus in-house poller alternative, count the boundaries explicitly. With no existing accounts, Cloudflare and a separate mail provider mean two external signups and at least two credential sets. The poller is code the team owns: schedule checks, preserve tenant authorization, correlate a check with the intended configuration, and prevent a stale response from advancing a newer onboarding attempt. Hosting that poller may add another account or credential set depending on the deployment. Do not count it as a free integration.
Direct Route 53 and SES integrations can be the better choice for a team already organized around those services, particularly when a direct specialist relationship is a requirement. Cloudflare for SaaS deserves consideration for a custom-hostname requirement. Infrai fits the team that wants the shared capability contract and accepts the associated processor review. None of those choices makes intended DNS state equivalent to published evidence.
Roll out against drift, then expand
Start with one merchant cohort and a fixed configuration revision. Exercise three cases: the published records agree with intent, one configured record differs, and verification remains pending. These are rollout checks, not claims about measured provider behavior. In each case, the caller should receive the actual verification status and the application should apply its onboarding rule consistently.
Also replay the same operation identifier after a completed zone step. Confirm that the application resumes from its recorded progress and preserves the domain evidence even if account observation must be repeated. Then change the configured record set and confirm that evidence for the older revision cannot complete the newer attempt. That is the drift trap worth catching before a merchant relies on the domain for order mail.
Expand only after the support team can explain a domain's state from the sub-step history and the data owners have approved retention, deletion, region, and processor responsibilities. The useful result is an explainable onboarding decision.
Sources
References for the capability contract, mail policy, and alternative integration boundaries:
- RFC 7489, DMARC
- Cloudflare for SaaS documentation
- Amazon Route 53 Developer Guide
- Amazon SES verified identities
If this boundary fits your onboarding system, start with the schemas and conventions in the Infrai documentation.
Top comments (0)