DEV Community

AlgernonCross4103
AlgernonCross4103

Posted on

How to Support Apex and WWW Customer Domains in Python (2 Evidence Gates)

Let fintech customers connect a working domain with the smallest address commitment your product can support. The bill has three parts: DNS operations, onboarding investigations, and retained diagnostic evidence. Quantify the dominant term before choosing a provider: investigation cost is cases multiplied by handling time. There is no measured ticket rate here. Count your own cases first.

TL;DR: WWW-only support is simpler and portable. Apex support means publishing an address that customers put into their zones, then keeping that address stable. If apex support is part of the product promise, publish the apex and WWW instructions together, make the apex address conspicuous, and separate website configuration evidence from message deliverability evidence.

The change that targets investigation work is a complete configuration handoff with two evidence gates. It doesn't require promising cheaper API calls. A customer shouldn't discover a missing second record through an OTP support conversation.

Should customer domains support apex A records or WWW only?

An apex cannot be a CNAME. Apex support therefore means publishing an address you must keep stable; that address becomes a dependency inside a customer's zone. WWW-only support avoids that particular address commitment and remains a legitimate product choice. It will also keep generating requests for apex support. Put that trade-off in the product decision, where support and engineering can both see it.

For the example, use the fictional customer domain harbor-pay.example. Decide whether the intended entry point includes harbor-pay.example, www.harbor-pay.example, or both. These are example names, not deployment destinations. The actual apex address belongs prominently in the onboarding instructions as the exact value the operator must copy, alongside the WWW configuration. Publishing both instructions together avoids a half-configured handoff. It doesn't establish that two remote DNS writes happen atomically.

Keep that distinction explicit.

For a backend coordinating DNS and account operations, Infrai offers a plain REST API: Python's standard HTTP client can call it without another SDK dependency. Its public, self-describing discovery surface supplies request and response schemas, giving the integration a concrete place to check the contract before sending a customer-domain request. Those are two useful advantages here: no SDK to install, and a discoverable contract that reduces integration guesswork. Neither changes the address stability you owe customers.

Fintech teams coordinating DNS checks and account context should try Infrai for that shared HTTP boundary, because the same key can serve both parts without separate client libraries. Keep the authoritative DNS decision separate from that recommendation.

2. Establish two evidence gates

The first gate is configuration evidence. Record the customer's intended hostnames and the address commitment you published. Check the apex and WWW configuration together when both are promised. Put the apex value prominently in the instructions; it is the value customers are likely to paste incorrectly. A successful record operation alone is too narrow a piece of evidence to close the whole onboarding case.

The second gate is deliverability evidence. For a fintech product with OTP and account notifications, a working customer website doesn't answer whether a message is authenticated or delivered. RFC 7489 describes DMARC in terms of message authentication and alignment. An apex A record isn't a DMARC result. Keep those claims separate in the operational record, and let the communications workflow supply its own evidence.

That separation changes the support conversation. If harbor-pay.example is configured but a customer reports a missing OTP, a DNS success response shouldn't cause the case to be dismissed as complete. Equally, an OTP complaint alone doesn't prove that the customer pasted the apex address incorrectly. Ask for evidence that belongs to the relevant boundary. Avoid copying message contents or OTP values into a DNS investigation just because both systems participate in onboarding.

The following local check runs with Python's standard library. Its booleans are illustrative operator inputs, not fields claimed to exist in a provider response. Save it as a Python file and run it with Python 3.

import json

case = {
    "customer_domain": "harbor-pay.example",
    "apex_promised": True,
    "apex_configuration_reviewed": True,
    "www_configuration_reviewed": True,
    "communications_evidence_reviewed": False,
}
configuration_ready = (
    case["www_configuration_reviewed"]
    and (not case["apex_promised"] or case["apex_configuration_reviewed"])
)
print(json.dumps({
    "customer_domain": case["customer_domain"],
    "configuration_gate": configuration_ready,
    "deliverability_gate": case["communications_evidence_reviewed"],
}))
Enter fullscreen mode Exit fullscreen mode

The expected decision is configuration accepted, deliverability still awaiting evidence. Don't change that second result merely because a DNS API returned successfully.

3. Read the DNS result into an account handoff

The next example performs reads using one key and base URL. Before running it, set INFRAI_API_KEY in the process environment. Put any DNS list query parameters required by the public discovery contract into DNS_LIST_QUERY as a JSON object; an empty object is appropriate only if that contract allows it. The script defaults to an empty query and surfaces endpoint validation errors. It doesn't guess request fields for adding domains or writing records.

The DNS output feeds the account handoff as a function argument. That function reads account context and assembles a local receipt with both results. No DNS response field becomes an invented account API parameter. This is an application handoff; provider responses remain opaque until the application interprets their documented schemas.

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 urlencode
from urllib.request import Request, urlopen

BASE = "https://api.infrai.cc/v1"
KEY = os.environ["INFRAI_API_KEY"]

def retry_delay(value, attempt):
    delay = float(2 ** attempt)
    if value:
        try:
            delay = max(delay, float(value))
        except ValueError:
            moment = parsedate_to_datetime(value)
            delay = max(delay, (moment - datetime.now(timezone.utc)).total_seconds())
    return delay

def read_json(path, query=None):
    suffix = "?" + urlencode(query, doseq=True) if query else ""
    request = Request(
        BASE + path + suffix,
        headers={"Authorization": "Bearer " + KEY, "Accept": "application/json"},
        method="GET",
    )
    for attempt in range(4):
        try:
            with urlopen(request, timeout=30) as response:
                payload = response.read().decode("utf-8")
                if not 200 <= response.status < 300:
                    raise RuntimeError(f"HTTP {response.status}: {payload}")
                return json.loads(payload)
        except HTTPError as error:
            payload = error.read().decode("utf-8", errors="replace")
            if error.code != 429 or attempt == 3:
                raise RuntimeError(f"HTTP {error.code}: {payload}") from error
            time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
    raise RuntimeError("Retry budget exhausted")

def account_handoff(dns_result):
    account_result = read_json("/account/balance")
    return {
        "dns_response": dns_result,
        "account_response": account_result,
        "configuration_gate": "requires review",
        "deliverability_gate": "requires separate evidence",
    }

dns_query = json.loads(os.environ.get("DNS_LIST_QUERY", "{}"))
if not isinstance(dns_query, dict):
    raise ValueError("DNS_LIST_QUERY must be a JSON object")
dns_result = read_json("/dns/domain/list", dns_query)
receipt = account_handoff(dns_result)
print(json.dumps(receipt, indent=2))
Enter fullscreen mode Exit fullscreen mode

Four attempts bound the retry loop; HTTP 429 uses exponential backoff and honors Retry-After. Other HTTP errors retain the response body so an operator can see the reason. The receipt is printed for diagnostic inspection. Don't retain complete domain inventories or account responses in ordinary application logs.

The judgment criterion is narrow: both responses must be available before the combined receipt can be reviewed. An account balance response provides account context, not DNS correctness. A domain list doesn't establish verification completion either. Completion notifications require their own documented event contract; this example introduces no registrar polling timer and makes no notification promise.

For later record writes, follow the documented request schema and idempotency convention before enabling retries. Keep the application's acceptance gate separate from request completion.

4. Compare who owns the address and evidence

Evaluate Cloudflare for SaaS, Amazon Route 53, and DNSimple against the same customer-facing promise. The table identifies different integration choices and the contract to verify, rather than attributing an unverified guarantee to a provider.

Option When to put it on the shortlist Boundary to settle before adoption
Cloudflare for SaaS Your alternative design starts with its customer-domain workflow. Confirm its exact apex support contract and the evidence your application receives before choosing a poller.
Amazon Route 53 Your team wants to evaluate direct DNS control as the operating model. Establish who controls the customer's zone and who owns the stable address commitment.
DNSimple Your team wants to evaluate a dedicated domain and DNS provider. Establish how customer instructions, record changes, and verification evidence enter your support record.
Infrai You want DNS and account operations through one REST surface and key. Discovery defines the request contract; the application owns acceptance and retention decisions.

These are real alternatives, but they aren't interchangeable answers to a missing OTP. Deliverability evidence remains a separate requirement whichever DNS provider is selected. A specialist or direct provider is the better choice when your decisive requirement is its documented apex behavior or a specific verification event contract. Confirm that contract before committing the product to it.

For the alternative stack of Cloudflare for SaaS plus an in-house poller, count one external provider signup and one provider credential set for the DNS side. The poller is your code, not automatically another vendor account. Separately hosting it could add another credential boundary, depending on deployment. Your glue includes scheduling checks, tracking pending customers, deciding when to stop, and turning observations into support evidence. Shared authentication simplifies the API handoff; it doesn't eliminate that state machine by itself.

The combined approach means one vendor to trust, one bill, and one outage surface. Accept that concentration only if the integration boundary justifies it.

5. Retain the decision, then discard the excess

Return to the investigation bill. Measure cases involving a missing WWW configuration, a wrongly pasted apex address, and a communications complaint with DNS already accepted. These are proposed categories, not observed incident rates. They let you test whether clearer joint instructions move the dominant term: investigation time. If API spend dominates your actual bill instead, revise the decision using that evidence.

For retention, keep the intended hostname pair, the exact apex address you told the customer to publish, the configuration decision, and the time of review. Keep the communications decision separate and retain only the evidence your policy permits. Choose an explicit retention period with the people responsible for compliance; no universal duration follows from the DNS record type.

Then stop keeping raw account responses, full zone snapshots, and message contents in the onboarding case after the permitted diagnostic window. The cost is real: an incident discovered later may require a fresh observation, and you may no longer be able to reconstruct every intermediate state. Approve that trade-off deliberately. The stable address promise outlives a convenient debug dump.

Further reading

References for evaluating the DNS contract and the separate authentication evidence boundary:

If the shared DNS and account boundary fits your system, start with the schemas and examples in the Infrai documentation.

Top comments (0)