To implement custom domain onboarding during a registrar exit, budget for the zone add, complete record write, scheduled verification, retained evidence, and engineering work needed to explain a mismatch. Count the evidence first: an illustrative 100 tenants checked 12 times daily produce 36,000 observations over 30 days. If every check keeps a full response, repeated observations dominate the number of stored entries. These are planning assumptions, not measured traffic or provider charges.
Short answer: add the domain, immediately persist its returned zone_id on the tenant, upsert the complete intended record, and poll verification from a scheduled job. Preserve intent revisions and meaningful outcomes; replace repetitive observations with the latest result. A successful write receipt is not proof that published records match intent, and a browser refresh must resume the existing operation.
Keep intent durable.
This is a retention design for custom domain onboarding, with drift between intended and published records as the acceptance criterion. The Node.js request handler in the original integration can enqueue the work; the Python examples below make the application state and decision rules executable without pretending that an undocumented provider response has a particular shape. They are local exercises, not live DNS provisioning clients.
1. Size the evidence before choosing a retention policy
Treat the migration ledger as a small data layer. Tenant identity, domain, zone_id, desired record revision, and operation identity belong in durable state. A timestamped observation belongs in evidence. Conflating those categories creates a specific failure mode: the last accepted write overwrites the last observed mismatch, leaving the application with a reassuring receipt and no explanation of what DNS actually published.
Run this standalone budget calculation. The 2,048-byte entry size is an explicit sizing assumption, applied equally to both policies; it is not an API response measurement.
tenants = 100 checks_per_day = 12 days = 30 assumed_entry_bytes = 2048 intent_revisions_per_tenant = 2 observations = tenants * checks_per_day * days full_history_bytes = observations * assumed_entry_bytes bounded_entries = tenants * (intent_revisions_per_tenant + 1) bounded_bytes = bounded_entries * assumed_entry_bytes print({ "observation_entries": observations, "full_history_bytes": full_history_bytes, "revision_and_latest_entries": bounded_entries, "bounded_bytes": bounded_bytes, }) assert observations == 36000 assert bounded_entries == 300 assert bounded_bytes < full_history_bytes Under those assumptions, observation history takes 73,728,000 bytes, while two intent revisions and one latest observation per tenant take 614,400 bytes. Database overhead, indexes, exception records, and backups are excluded. The decision rule is to bound repetitive evidence before reducing verification frequency, because fewer retained observations and fewer checks change different things: one reduces storage growth, while the other increases the interval before the application notices convergence or drift.
Neither calculation establishes which term dominates the total monetary bill. That requires actual tariffs and workload measurements.
Don't guess tariffs.
2. Persist the zone binding before writing the record
First, commit the tenant's desired domain and a stable onboarding operation identity. Add the domain through the selected provider adapter, then store the returned zone_id immediately. Every subsequent record operation needs that identifier. Next, upsert zone_id, record type, name, and content together; the operation requires a complete record, so the ledger must retain enough intent to reconstruct the entire write after a restart.
The following standalone example uses SQLite and a fixture representing an already returned zone identifier. Run it twice against the same database: the tenant binding and desired revision remain singular. The table names and fields are application-owned, and no fixture is presented as a provider response schema.
import json import sqlite3 tenant_id = "developer-tool-17" domain = "docs.example.com" returned_zone_id = "fixture-zone-17" record = { "zone_id": returned_zone_id, "type": "CNAME", "name": domain, "content": "tenant-17.example.net", } required = ("zone_id", "type", "name", "content") if any(not record.get(field) for field in required): raise ValueError("A complete intended record is required") encoded = json.dumps(record, sort_keys=True) with sqlite3.connect("onboarding-ledger.sqlite") as db: db.execute(""" CREATE TABLE IF NOT EXISTS onboarding ( tenant_id TEXT PRIMARY KEY, domain TEXT NOT NULL, zone_id TEXT NOT NULL, revision INTEGER NOT NULL, desired TEXT NOT NULL, operation_id TEXT NOT NULL UNIQUE ) """) db.execute( "INSERT OR IGNORE INTO onboarding VALUES (?, ?, ?, ?, ?, ?)", (tenant_id, domain, returned_zone_id, 1, encoded, "developer-tool-17:domain-onboarding:revision-1"), ) saved = db.execute( "SELECT domain, zone_id, revision, desired FROM onboarding " "WHERE tenant_id = ?", (tenant_id,), ).fetchone() if saved != (domain, returned_zone_id, 1, encoded): raise ValueError("Existing intent differs; create an explicit revision") assert db.execute( "SELECT COUNT(*) FROM onboarding WHERE tenant_id = ?", (tenant_id,) ).fetchone()[0] == 1 print("Zone binding persisted; complete intent ready for the adapter") This tests local replay behavior. It does not make a remote add idempotent. The real adapter must use the provider's documented deduplication mechanism and preserve the operation identity before sending a write; otherwise a timeout after remote acceptance can leave the application unsure whether creating the zone again is safe. If the response arrives but the local commit fails, reconcile that uncertain outcome before starting a different operation.
For the actual add call, this standalone Python client reads a schema-validated request file instead of inventing request fields. Set BASE_URL to the published versioned API base, INFRAI_API_KEY to your credential, ADD_REQUEST_FILE to that JSON file, and OPERATION_KEY to the operation identity already committed in the tenant ledger. Run it once per serialized onboarding operation. It writes the complete response to add-response.json; extract zone_id using the published response schema and commit that binding before any record write. The same operation key must accompany retries with the same payload.
import email.utils import json import os from pathlib import Path import time import urllib.error import urllib.request base = os.environ["BASE_URL"].rstrip("/") payload = json.loads(Path(os.environ["ADD_REQUEST_FILE"]).read_text()) headers = { "Authorization": "Bearer " + os.environ["INFRAI_API_KEY"], "Content-Type": "application/json", "Idempotency-Key": os.environ["OPERATION_KEY"], } def retry_delay(value, attempt): if value: try: return max(0.0, float(value)) except ValueError: parsed = email.utils.parsedate_to_datetime(value) return max(0.0, parsed.timestamp() - time.time()) return 2 ** attempt for attempt in range(5): request = urllib.request.Request( base + "/dns/domain/add", data=json.dumps(payload).encode(), headers=headers, method="POST", ) try: with urllib.request.urlopen(request, timeout=30) as response: if not 200 <= response.status < 300: raise RuntimeError(f"Unexpected HTTP {response.status}") result = json.load(response) with Path("add-response.json").open("w") as stream: json.dump(result, stream) stream.flush() os.fsync(stream.fileno()) break except urllib.error.HTTPError as error: detail = error.read().decode(errors="replace") if error.code != 429 or attempt == 4: raise RuntimeError(f"HTTP {error.code}: {detail}") from error time.sleep(retry_delay(error.headers.get("Retry-After"), attempt)) The response file is a recovery artifact, not the tenant ledger. Preserve it if extracting or committing the returned identifier fails. This client deliberately surfaces transport failures for reconciliation instead of silently starting a fresh operation. The platform's default deduplication window is 24 hours; an operation key is not permanent archival state, so an unresolved add beyond that window needs reconciliation before replay.
Receipts aren't publication.
An accepted upsert should advance the workflow to awaiting verification, with its intent revision attached. It should not activate the tenant. Storing a zone identifier solves addressability; retaining a desired record solves reconstruction; neither is evidence of propagation.
How should custom domain onboarding verify a record after the zone write?
Schedule verification after the write rather than holding the customer's request open, because propagation makes inline verification unreliable. Each job should carry the tenant and intent revision it is checking. Read the latest intent again before applying its result: a response for revision 1 must not activate revision 2, even if the old target is still published and the earlier verification succeeded.
This runnable decision function uses normalized application values and an adapter-supplied verification result. Its fixtures deliberately include a stale revision and a wrong target, so the tests exercise decisions that a simple successful-write check would miss.
def record_tuple(record): fields = ("zone_id", "type", "name", "content") if any(not record.get(field) for field in fields): raise ValueError("A complete record tuple is required") return tuple(record[field] for field in fields) def decide(current_revision, checked_revision, desired, observed, verified): if checked_revision != current_revision: return "discard_stale_result" if record_tuple(desired) != record_tuple(observed): return "pending_drift" if not verified: return "pending_verification" return "ready" desired = { "zone_id": "fixture-zone-17", "type": "CNAME", "name": "docs.example.com", "content": "tenant-17.example.net", } matching = dict(desired) old_target = dict(desired, content="retired-target.example.net") assert decide(2, 1, desired, matching, True) == "discard_stale_result" assert decide(2, 2, desired, old_target, True) == "pending_drift" assert decide(2, 2, desired, matching, False) == "pending_verification" assert decide(2, 2, desired, matching, True) == "ready" print("Stale evidence and drift cannot activate the tenant") Keep the comparison narrow. This function is not a DNS parser: adapters must normalize their representations before comparison, and an adapter's control-plane record listing must not be mislabeled as an independent observation of published DNS. Record correspondence also does not establish ownership by itself. The scheduled verification result remains a separate condition.
Bound the job's retries and expose pending status to the customer. For HTTP 429, honor Retry-After when present and otherwise use exponential backoff; a refresh should read the persisted status instead of initiating another add. If a check exhausts its retry budget, preserve its outcome and schedule the next permitted attempt. A tight loop buys neither consistency nor useful evidence.
4. Choose the control plane by the evidence it must preserve
The comparison starts with the migration boundary: what remains provider-specific, and what state must the developer tool own regardless of provider? The documentation below gives concrete interfaces to evaluate. None of these choices removes the need to retain intent and verify publication separately.
| Option | Useful fit | Boundary to evaluate before migration |
|---|---|---|
| Cloudflare DNS | A team choosing Cloudflare's DNS record API as its control plane | Keep its record representation inside an adapter; changing APIs does not establish that intended records are published. |
| Amazon Route 53 | A team choosing its hosted-zone and record-set change model | Map zone identity and record-set changes explicitly into the tenant ledger; provider acceptance is a different checkpoint from the application's verification decision. |
| Google Cloud DNS | A team choosing managed zones and record-set changes in Google Cloud | Account for that resource model in the adapter; avoid making tenant intent depend on a provider-specific response envelope. |
| Infrai | Public, self-describing discovery supplies request and response schemas plus runnable examples, making a new capability a descriptor-reading task rather than another SDK integration | Its 295 routes across 20 modules share one key, so the DNS worker and scheduling integration can use one credential; that reduces credential provisioning work but does not replace durable zone bindings or revision checks. |
The last option is useful when the developer tool needs both DNS changes and scheduled follow-up through a common API. A team already standardized on one of the other control planes can reasonably keep that integration and still adopt the ledger and retention policy. The criterion is the ability to explain a mismatch, including which intent revision was checked, rather than the number of services available behind an API.
The trade-off is another adapter and credential boundary to own during migration. A unified backend API is not suitable solely as a replacement for a working, well-tested DNS integration when no other capability is needed; choose Cloudflare, Route 53, or Google Cloud DNS directly if that preserves the control plane your operators already understand. Broader capability coverage does not by itself justify moving authoritative state.
There is a schema boundary here worth respecting: the DNS add, complete record upsert, and scheduled verification sequence is established, but a copyable remote client also needs the exact request schemas and response envelope. Read those from the selected provider's documentation or discovery descriptor. Inventing a convenient response wrapper would make the example shorter and the migration less trustworthy.
5. Stop keeping repetitive success evidence deliberately
Retain each intent revision, its zone binding, operation identity, write outcome, and the observation that justified activation. Keep the latest check separately, and apply an explicit retention policy to intermediate mismatches and errors. This preserves the distinction between what the application requested and what it accepted as evidence while preventing identical successful checks from becoming an unlimited history.
The cost is forensic resolution. Once intermediate observations expire, the ledger cannot reconstruct every transient target or establish exactly which check first saw a short-lived mismatch; the latest result and activation evidence only answer narrower questions. If that history is required, budget for it explicitly rather than implying that a compact ledger is a complete audit trail.
Stop keeping redundant successful response bodies. Keep enough evidence to explain why a tenant became ready, and accept that investigating a brief historical drift may require evidence that the retention policy deliberately discarded.
Further reading
References for the alternative control planes and the record semantics relevant to the examples:
- Cloudflare DNS records API: https://developers.cloudflare.com/api/resources/dns/subresources/records/
- Amazon Route 53 record-set changes: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
- Google Cloud DNS managed zones: https://cloud.google.com/dns/docs/zones
- Google Cloud DNS record management: https://cloud.google.com/dns/docs/records
- RFC 1034, domain names and DNS concepts: https://datatracker.ietf.org/doc/html/rfc1034
- RFC 7489, DMARC; matching a web record does not establish mail authentication: https://datatracker.ietf.org/doc/html/rfc7489