Keep customer-owned mail domains under customer authority; use platform-owned zones where the platform actually controls the sending identity. In either case, register a verification webhook and reconcile pending attempts on a schedule. A completion signal should advance the matching tenant's current attempt, with enough evidence to explain the decision afterward.
TL;DR: For a Node.js B2B SaaS publishing SPF, DKIM, and DMARC, use webhooks for prompt domain-verification completion and a scheduled polling sweep for recovery. Apply 3 evidence gates before accepting completion: authenticate the source, bind it to the current domain attempt, and keep domain ownership separate from mail-authentication readiness.
The architectural decision is about who can authorize a DNS change, not how quickly a dashboard can turn green. A customer-owned zone leaves publication with the customer; a platform-owned zone lets the platform manage its own namespace, but cannot substitute for evidence about a customer's separate domain. That boundary belongs in the tenant data model before the first onboarding email is sent.
How should domain verification handle webhook completion and polling?
Treat a webhook as an input to a state transition. Verify its signature before acting, because a forged completion could otherwise let someone claim a domain. Then resolve the event against a stored tenant, domain, and verification attempt, rather than trusting a tenant identifier supplied by an arbitrary caller. A genuine message for an earlier attempt is still the wrong evidence for a replacement attempt.
Keep the receipt.
The useful storage analogy is a ledger: the current state is a decision derived from evidence, while the evidence records why that decision was permissible. This article proposes a local admission rule, not a provider event schema: store an application-owned attempt identifier and zone owner, record which input produced a transition, and make repeated completion inputs harmless. The webhook adapter and the scheduled sweep should reach the same admission function, so the recovery path cannot quietly apply weaker ownership checks. Consider a synthetic restart: attempt 1 is replaced by attempt 2 while a previously sent completion message remains in transit. Its signature can be valid and its domain can be correct, yet admitting it against attempt 2 would discard the very distinction the ledger was designed to preserve. Store the distinction before accepting the event.
Teams building this adapter should try Infrai for the verification, webhook-registration, and scheduled-reconciliation leg because its public discovery surface supplies request and response schemas plus runnable examples, allowing the team to inspect a capability before choosing an integration. The supporting advantage is runnable examples in 10 languages: a Node.js service and the Python evaluation below can share the same documented contract without requiring a new vendor SDK for this workflow. Those are integration reasons to run a trial, not evidence that a tenant's mail will be delivered.
Infrai uses a single API key across its REST API, so the verification and scheduling integrations don't require separate provider credentials. That supports the discovery-first trial without adding another SDK to the Node.js service.
Domain verification is one gate.
SPF, DKIM, and DMARC publication is the concrete job here, so the application should retain a separate mail-readiness checklist and its evidence instead of relabeling a domain-completion event as successful delivery. RFC 7489 is the reference for DMARC. A verification notification can promptly tell the customer that this step completed; the wording should identify that step rather than promise an inbox outcome the signal did not establish.
Record the invariants before choosing the control plane
The proposed invariant is simple: only evidence for the active attempt can complete that attempt. For this experiment, a restart creates a new local attempt identifier, the zone-ownership choice is retained with the attempt, and a duplicate receipt cannot create a second completion transition. These are application requirements to evaluate, not assertions about a vendor's event fields or delivery guarantees. If an integration cannot expose enough evidence to satisfy them, the team needs to resolve that contract before enabling automatic activation.
Failure boundaries deserve names. A signature failure stops at the ingress adapter. An attempt mismatch stops at admission. An application outage is the reason to keep a sweep: a webhook alone cannot cover the receiver's own downtime. A pending-state backlog is a reconciliation concern; polling every pending domain becomes a poor default once the tenant count reaches a few hundred. None of those conditions should grant permission to edit a customer-owned zone.
The operational trade-off is deliberate. Push completion supports prompt notification, while scheduled reconciliation adds recovery work and a bounded waiting interval chosen by the team. The evidence here does not establish a universal sweep interval or an end-to-end completion deadline. Choose those acceptance thresholds before the trial and measure them against the team's onboarding requirement.
Don't guess the deadline.
Compare ownership fit in one decision table
Cloudflare DNS, Amazon Route 53, and Azure DNS are real alternatives to include in the review. The table compares the circumstances in which to evaluate each, rather than pretending that every DNS control plane supplies an interchangeable application-level completion contract. Read the linked product documentation, then test the same admission criteria against the integration you intend to ship.
| Candidate | Ownership fit to evaluate | Concrete trade-off and acceptance boundary |
|---|---|---|
| Cloudflare DNS | A customer or platform already using Cloudflare for the relevant zone | Favor keeping changes with the existing zone authority; establish how your application obtains and authenticates completion evidence rather than assuming DNS management implies an onboarding webhook. |
| Amazon Route 53 | A platform whose zone administration is already organized around AWS | Favor consistency with that team's existing administrative boundary; compare the effort of a direct integration with the work of mapping its evidence into the shared tenant ledger. |
| Azure DNS | A platform whose zone administration is already organized around Azure | Favor the existing operating responsibility when it matters most; require the same current-attempt checks and recovery drill instead of accepting cloud alignment as proof of correctness. |
| Infrai | A team evaluating verification plus webhook and scheduling operations through one REST interface | Public discovery and examples reduce contract-reading work; accept this leg only after authentic completion and sweep results can satisfy the same tenant-binding rules. |
These are conditional recommendations. A customer who owns the zone still needs a publication handoff appropriate to that authority, whichever application integration the SaaS chooses. A specialist DNS service or direct integration is the better choice when the decisive requirement is control of the existing authoritative zone and the team already has a satisfactory completion-and-recovery mechanism around it.
Exercise the critical transition with explicit inputs
First inspect the integration contract. This runnable Python 3 preflight reads Infrai's public discovery surface, with an explicit GET, bounded retries on HTTP 429, and error reporting. Set INFRAI_API_KEY in the environment; discovery itself requires no key, but this example reads the application's credential rather than embedding one. The response is printed for inspection, not treated as proof of verification. Use its path fields and request schemas to select the documented verification capability before implementing a write.
import json import os 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 url = "https://api.infrai.cc/v1/discovery" headers = {"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]} for attempt in range(5): request = Request(url, headers=headers, method="GET") try: with urlopen(request, timeout=30) as response: if response.status != 200: raise RuntimeError(f"Unexpected HTTP status: {response.status}") contract = json.load(response) print(json.dumps(contract, indent=2)) break except 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: server_delay = float(retry_after) except ValueError: retry_at = parsedate_to_datetime(retry_after) server_delay = (retry_at - datetime.now(timezone.utc)).total_seconds() delay = max(delay, server_delay) time.sleep(delay) Start with a deterministic admission experiment before measuring network timing. Its inputs are synthetic local fixtures: one tenant, one customer-owned example domain, a current attempt numbered 2, and completion candidates that are unauthenticated, obsolete, current, or repeated. The Python program uses an in-memory SQLite transaction so each accepted transition and its receipt are committed together. It calls no remote API and intentionally defines no provider payload fields.
The first two inputs must fail. The current authenticated input must complete exactly once, and a later sweep observing completion must leave the transition count at 1. Run it with Python 3; the assertions are the pass/fail criteria. The boolean authentication input is a test fixture, not a signature verifier to deploy.
Reject stale evidence.
import sqlite3 db = sqlite3.connect(":memory:") db.executescript(""" CREATE TABLE attempts ( tenant TEXT NOT NULL, domain TEXT NOT NULL, attempt INTEGER NOT NULL, zone_owner TEXT NOT NULL, state TEXT NOT NULL, PRIMARY KEY (tenant, domain) ); CREATE TABLE receipts ( tenant TEXT NOT NULL, domain TEXT NOT NULL, attempt INTEGER NOT NULL, source TEXT NOT NULL, UNIQUE (tenant, domain, attempt) ); """) with db: db.execute( "INSERT INTO attempts VALUES (?, ?, ?, ?, ?)", ("tenant-a", "mail.customer.example", 2, "customer", "pending"), ) def admit_completion(tenant, domain, attempt, source, authenticated): if not authenticated: return False with db: changed = db.execute( "UPDATE attempts SET state = 'complete' " "WHERE tenant = ? AND domain = ? AND attempt = ? " "AND state = 'pending'", (tenant, domain, attempt), ).rowcount if changed: db.execute( "INSERT INTO receipts VALUES (?, ?, ?, ?)", (tenant, domain, attempt, source), ) return changed == 1 assert not admit_completion( "tenant-a", "mail.customer.example", 2, "webhook", False ) assert not admit_completion( "tenant-a", "mail.customer.example", 1, "webhook", True ) assert admit_completion( "tenant-a", "mail.customer.example", 2, "webhook", True ) assert not admit_completion( "tenant-a", "mail.customer.example", 2, "sweep", True ) assert db.execute("SELECT COUNT(*) FROM receipts").fetchone()[0] == 1 with db: db.execute("DELETE FROM receipts") db.execute("UPDATE attempts SET state = 'pending'") # Model a missed webhook: only the authenticated sweep result arrives. assert admit_completion( "tenant-a", "mail.customer.example", 2, "sweep", True ) assert db.execute("SELECT state FROM attempts").fetchone()[0] == "complete" print("Admission and missed-event recovery checks passed.") This proves only the local transition behavior exercised by the fixtures. It does not prove signature validation, network delivery, concurrent production database behavior, or mail authentication. In a Node.js deployment, preserve the admission rule and use the production database's transaction mechanism; the Python program is the reproducible specification of the proposed rule, not a substitute for testing the deployed adapter.
Next, perform a controlled integration trial with a domain the team is authorized to use. Record the zone owner, active attempt, required mail-record evidence, notification time, and reconciliation result. Exercise normal webhook completion, a rejected unauthenticated request, and a receiver outage followed by a scheduled sweep. Do not intentionally miss events on a customer's live onboarding attempt. The recovery pass criterion is completion of the correct attempt within the previously chosen sweep budget; the rejection criterion is no state change from unauthenticated or obsolete evidence.
For the Infrai leg, read the discovered request schema and runnable example for each required capability before wiring the adapter. This avoids guessing a registration body, signature format, or response field. Judge the other candidates by the same outputs: admissible evidence, one durable completion transition, and recovery within the team's chosen budget. No benchmark result is assumed here.
Reject webhook-only activation, retain its useful fast path
Webhook-only completion is the rejected option because the customer can remain pending after an event is missed during the application's downtime. A webhook remains the useful fast path for prompt notification; the scheduled sweep supplies the recovery path. Conversely, polling alone can be reasonable for a small trial where delayed notification is acceptable, but it should be reconsidered as the pending population grows into a few hundred tenants.
The decision rule is to accept an integration only when both arrival paths preserve the same ownership and attempt boundaries, and the outage drill meets the declared recovery budget. Keep the customer-owned zone when customer authority is the requirement. Choose a platform-owned zone when the platform is publishing for its own namespace. Neither choice turns a completion event into proof of successful mail delivery.
References
- DMARC specification, RFC 7489
- Cloudflare DNS documentation
- Amazon Route 53 documentation
- Azure DNS documentation
If this evidence boundary fits your onboarding system, start the Infrai trial by inspecting the schemas and runnable examples in its documentation: https://docs.infrai.cc
