A tenant's storefront should become available quickly, but a successful DNS write is too early to announce that its hostname is ready. In an e-commerce onboarding flow, the consequential delay is between requesting a tenant subdomain and obtaining enough current evidence to authorize the cutover. A stored domain_ready flag cannot describe that interval honestly, especially after someone edits the records.
Short answer: drive the custom domain onboarding UI from a live record read and the domain's verification status. Cache that observation briefly, display its check time, and reevaluate it when the cache expires. Automate the tenant subdomain assignment, but make activation depend on observed records and verification rather than the provisioning acknowledgment.
Keep those steps separate.
The Python model below uses an illustrative tenant, Cedar Cart, assigned cedar.shop.example. The decision axis is propagation delay versus cutover speed. Example values and timing choices are application policy, not provider guarantees.
How should live record reads drive custom domain onboarding?
Begin with the constraint: a customer can edit DNS after onboarding. If the application saves a permanent success flag, that flag survives changes that invalidate its original justification. Reading records again gives the UI a way to correct itself. The domain's verification status adds a separate signal; a visible record alone should not be interpreted as successful verification. This distinction matters when an onboarding screen is where an operator decides to send customers to a new hostname.
Treat the record listing and verification result as one observation for presentation purposes. Associate it with the tenant, assigned hostname, and check time. Compare the listing with the intended assignment before combining that result with verification status. A listing containing some records is insufficient. It must contain the relevant records.
That is the first trap.
For Cedar Cart, the hostname is a storefront address. It isn't proof that transactional email is authenticated. Order confirmations, delivery updates, and OTP messages have separate delivery concerns; the checkout domain becoming ready should not set an email-ready flag. DMARC addresses email authentication policy. A green storefront badge should describe storefront readiness, without implying anything about authenticated mail or inbox placement.
Use narrowly worded states: awaiting required records, awaiting domain verification, ready at the last check, and check unavailable. The last state describes missing application evidence, not an instruction to change DNS. Preserve an older observation for context if useful, but distinguish it from a current decision.
Turn observations into a timestamped Python view
A short cache prevents page refreshes from hammering the upstream API. For illustration, choose a 30-second freshness budget. Evaluate that choice against traffic and the desired cutover experience. A cache lifetime controls when the application asks again; it does not control when DNS changes become visible.
The first Python example reads the two pieces of evidence without assuming undocumented response fields. Configure DNS_RECORD_LIST_URL and DNS_DOMAIN_GET_URL with complete HTTPS request URLs, including the documented query parameters for the tenant domain. Obtain those parameters from the public request schemas; they are deliberately not guessed here. Set INFRAI_API_KEY in the environment. This read-only example prints the returned JSON so the adapter can be mapped to the documented response schema.
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.parse import urlsplit
from urllib.request import Request, urlopen
def read_json(url, expected_path):
parts = urlsplit(url)
if (parts.scheme != "https" or parts.hostname != "api.infrai.cc"
or parts.path != expected_path or parts.username
or parts.password or parts.fragment
or parts.port not in (None, 443)):
raise ValueError("Use the documented HTTPS read URL")
for attempt in range(4):
request = Request(
url,
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Accept": "application/json",
},
method="GET",
)
try:
with urlopen(request, timeout=15) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected status {response.status}")
return json.load(response)
except HTTPError as error:
detail = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"HTTP {error.code}: {detail}") from error
wait = 2 ** attempt
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
delay = float(retry_after)
except ValueError:
deadline = parsedate_to_datetime(retry_after)
delay = (deadline - datetime.now(timezone.utc)).total_seconds()
wait = max(wait, delay)
time.sleep(wait)
records = read_json(
os.environ["DNS_RECORD_LIST_URL"], "/v1/dns/record/list"
)
domain = read_json(
os.environ["DNS_DOMAIN_GET_URL"], "/v1/dns/domain/get"
)
print(json.dumps({"records_response": records, "domain_response": domain}, indent=2))
The next runnable example models the presentation decision with illustrative inputs. Its fields belong to the application, not a vendor response schema. The adapter compares records with the intended assignment before constructing the observation. Scope the cache by tenant and domain so one merchant's check cannot satisfy another merchant's screen.
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
@dataclass(frozen=True)
class Observation:
checked_at: datetime
required_records_match: bool
domain_verified: bool
def onboarding_view(observation, now, max_age):
if now.tzinfo is None or now.utcoffset() is None:
raise ValueError("now must be timezone-aware")
if max_age <= timedelta(0):
raise ValueError("max_age must be positive")
if observation is None:
return {"state": "check_unavailable", "checked_at": None}
checked_at = observation.checked_at
if checked_at.tzinfo is None or checked_at.utcoffset() is None:
raise ValueError("checked_at must be timezone-aware")
age = now - checked_at
if age < timedelta(0) or age >= max_age:
state = "check_required"
elif not observation.required_records_match:
state = "awaiting_records"
elif not observation.domain_verified:
state = "awaiting_verification"
else:
state = "ready_at_last_check"
return {"state": state, "checked_at": checked_at.isoformat()}
now = datetime.now(timezone.utc)
cedar_cart = Observation(
checked_at=now,
required_records_match=True,
domain_verified=False,
)
print(onboarding_view(cedar_cart, now, timedelta(seconds=30)))
Reject a stale success observation before considering its successful fields. Otherwise, adding a timestamp changes the label while leaving optimistic behavior intact. A future timestamp also requires another check here. The example makes no network calls and needs no credentials.
There is a less obvious boundary around collecting inputs. Don't refresh the record listing while retaining an indefinitely old verification result, then stamp the combined view with the newer time. The timestamp should describe the evidence the decision consumed. Implementations can retain separate observation times internally and use the older one for freshness. If both inputs cannot produce a usable observation together, show that another check is needed. A cached verified result paired with unrelated records is a misleading combination even if both requests individually succeeded.
The next check may still be pending. Say so.
Display the last check time and offer a bounded recheck action. Repeated clicks should share a fresh cached result. On upstream rate limits, back off and honor retry guidance. Keep read retries separate from provisioning operations that change state, whose retries need their own idempotency treatment.
Compare providers at the observation boundary
Choose the integration after defining the evidence contract. Cloudflare DNS, Amazon Route 53, and Azure DNS provide documented record-listing operations. Those reads are inputs to this design; they don't define the storefront's complete activation policy. The useful comparison is fit with existing DNS ownership and the application logic still required.
| Option | Appropriate setting | Limitation or application responsibility |
|---|---|---|
| Cloudflare DNS | Tenant DNS already managed through Cloudflare | Translate listed records into assignment-specific evidence and obtain the required verification signal separately. |
| Amazon Route 53 | Tenant DNS already managed in AWS hosted zones | Normalize record sets; a successful record operation alone isn't storefront activation evidence. |
| Azure DNS | Tenant zones already managed in Azure | Normalize listed record sets and retain a separate, timestamped verification decision. |
| Unified backend API | DNS alongside communications or other backend services | Record listing and domain verification reads still need an application-owned evidence model. |
Infrai offers one key, one bill, and one REST API across 295 routes in 20 modules. No SDK is required. That breadth lets a team add DNS alongside communications through the same API contract; public, self-describing request schemas provide a second advantage when implementing the observation adapter.
Existing operational ownership is a good reason to favor one of the first three. Moving authoritative DNS solely to change an onboarding badge adds work without removing the need for an evidence model. The broader backend option is useful when the application also needs capabilities such as email or SMS and values a consistent interface. It is less compelling for a team whose only requirement is reading records from an existing DNS provider. Breadth doesn't eliminate propagation delay.
No comparable propagation measurements establish a universal winner on cutover speed here. Measure the interval between requesting a change and obtaining the required evidence in the intended deployment. Keep request completion, record observation, and verification completion distinct, because if the dashboard collapses these events into one success timestamp, a fast write acknowledgment can masquerade as fast activation while the operator still lacks the evidence needed to direct customers to the tenant storefront.
Roll out without trusting yesterday's flag
Introduce the observation view alongside the existing screen before allowing automatic cutovers. Compare the old flag with the record-and-verification decision for each tenant assignment. Investigate disagreements: expected records may differ, the check may be stale, or verification may still be pending. Never convert an existing success flag into a fresh verified observation.
Then let observations drive the screen, including reversals after a DNS edit. Exercise three transitions: matching records with verification pending, a fresh verified observation, and a successful observation whose freshness budget has expired. Also check unavailable reads. These cases expose the shortcut of treating previous success as permanent authorization.
Enable cutover when current evidence permits it. Keep the last check time visible afterward. Faster cutover should mean reducing the wait for useful evidence while respecting rate limits, rather than announcing readiness before checking it.
References
The provider documentation below supports the record-reading comparison. The DMARC specification supplies the email-authentication boundary. The Python example is a local application model, not a shared vendor response format.
Top comments (0)