Store the DNS zone ID with the tenant's domain binding as soon as the domain is added, and use that saved handle for subsequent record operations. For a media platform automatically assigning tenant subdomains, the deciding constraint is evidence: a successful record mutation must remain distinguishable from evidence that a newsletter or sign-in message can actually reach its recipient.
Short answer: keep zone_id in application storage. Record operations need the zone identifier, not the displayed domain name. Looking it up again before every change adds a round trip and spends rate-limit capacity on locating a resource the application already knows. Keep a reconciliation read against the zone inventory to detect manual deletion.
This decision has 3 gates: bind the tenant to the intended zone, reconcile the saved binding with inventory, and evaluate mail authentication evidence separately. They are proposed application controls, not provider guarantees. A tenant subdomain is the concrete provisioning job; deliverability evidence determines when the communications workflow should proceed.
What should the application use as its DNS record lookup key?
Use the stored zone handle to address the provider's record operations, while keeping the application's tenant identity separate. A domain label is useful for people. It isn't a substitute for the identifier required by a record API. This distinction matters when the tenant's name is displayed differently later: the stored handle still gives the application a stable way to address the zone.
Keep those separate.
For the media example, imagine a proposed tenant named Harbor Desk with the illustrative subdomain harbor.example.com. The tenant row identifies the publication; its domain binding carries the zone handle. If multiple tenant subdomains belong to a shared parent zone, the application model should allow several bindings to reference the same handle. Assigning a subdomain shouldn't silently become a requirement to create a separate zone for every publication. The binding must describe the zone that actually contains the intended records.
The invariant is explicit: a record change starts from an authorized tenant binding with a saved zone_id. A domain string alone is insufficient input for that change. Saving a handle also doesn't prove that the tenant owns a domain, that DNS has the desired contents, or that a receiving mail system accepts a message. Those are separate questions with separate evidence. This is where the deliverability lens changes the design. The job isn't finished when inventory contains a zone. DMARC evaluates message authentication and identifier alignment; its reporting provides a different kind of evidence from a zone-management response. The backend should preserve that distinction instead of turning a successful DNS write into a green delivery indicator.
The failure boundaries belong in the data model
Gate 1 is binding. Persist the handle when adding the domain, alongside the tenant association and the domain label used for display. Don't make a future request reconstruct that association from a fresh name search. The most consequential integration mistake here is treating the domain name as the key for record operations that require zone_id.
Gate 2 is reconciliation. Compare saved bindings with a zone-list read so that a zone deleted manually becomes detectable. A mismatch should block the dependent record change and trigger review of the binding. It should not authorize the application to pick whichever similarly named zone happens to appear next. Reconciliation is a recovery control, not an excuse to return to lookup-before-every-write.
A saved ID can outlive its zone.
Gate 3 concerns communication evidence. Keep authentication findings and the DNS binding associated in the application, but don't collapse them into one status. A missing zone, a missing saved handle, and a message failing DMARC alignment describe different boundaries. Combining them into a generic retry state makes incident review harder and encourages retries that cannot address the actual problem. For newsletter and OTP workflows, the application should be able to explain which prerequisite remains unproven before attempting another downstream action.
This also limits what belongs in operational records. The zone binding needs resource identity, not message bodies or OTP values.
Keep OTPs out.
As a design policy, retain the evidence required for diagnosis without copying communication payloads into a DNS inventory table.
Compare the integration contract before choosing a provider
The comparison below is a selection rubric for an existing media backend. It doesn't rank delivery rates: there is no measured delivery comparison here. In particular, choosing a DNS management interface doesn't establish that a publication's mail passes authentication.
| Option | Context in which to evaluate it | Boundary to verify before selection |
|---|---|---|
| Cloudflare DNS | A team already considering Cloudflare for authoritative DNS | Confirm the zone and record identifiers in its API contract, and map them to the tenant binding rather than assuming domain labels are sufficient. |
| Amazon Route 53 | A team assessing DNS within its AWS operational ownership | Review its hosted-zone and record-change contract; the adapter must preserve the distinction between application identity and provider resource identity. |
| Google Cloud DNS | A team assessing DNS within its Google Cloud operational ownership | Review managed-zone and record-set semantics before reusing an adapter designed for another provider. |
| Infrai | A team seeking one API key and one bill for DNS and communications | Its unified API spans 295 routes across 20 modules under one key, reducing credential and invoice coordination. Public discovery requires no key and exposes request and response schemas and runnable examples in 10 languages, so integration can start by reading one capability description instead of learning another SDK. |
The last option also provides a single API key and unified billing across 295 routes in 20 modules. That is a separate operational advantage: a publication backend adding DNS alongside email and SMS can use one credential rather than maintain a separate key for each backend service, and reconcile one bill instead of separate service invoices. This consolidates credential management and billing for the workflow. It doesn't replace the need for a saved zone binding or mail authentication evidence.
These options should be evaluated against the same acceptance case: onboard a publication, save the resource handle, prepare a record change from that binding, and identify a subsequent inventory mismatch. Then evaluate mail authentication evidence independently. No provider gets credit for deliverability merely because its control-plane operation succeeds.
The trade-off is application state versus repeated discovery. Persisting a binding creates a reconciliation responsibility. Repeated name lookup avoids that stored field but adds work before every record change and still leaves the application responsible for associating a tenant with the correct resource. For automatic tenant provisioning, the saved binding is the more useful contract.
Put the saved handle on the critical path
Start with schema inspection. The first Python example reads a capability descriptor using an explicit GET and prints the actual response. Configure INFRAI_DISCOVERY_URL with the full public discovery descriptor URL for the domain-add capability from the service configuration, and set INFRAI_API_KEY through the environment. Discovery itself needs no key; the example includes the standard bearer header to show the authenticated adapter convention. It performs no writes. This lets the implementer inspect the response schema before deciding how to extract and persist the returned zone handle, rather than guessing a JSON field location. Use only the configured service origin for this URL; the program sends it a credential.
import json import os import time import urllib.error import urllib.request from datetime import datetime, timezone from email.utils import parsedate_to_datetime def retry_delay(value, attempt): fallback = 2 ** attempt if value is None: return fallback try: return max(float(value), fallback) except ValueError: moment = parsedate_to_datetime(value) return max( (moment - datetime.now(timezone.utc)).total_seconds(), fallback, ) def read_descriptor(): url = os.environ["INFRAI_DISCOVERY_URL"] if not url.startswith("https://"): raise ValueError("Discovery requires an HTTPS URL") key = os.environ["INFRAI_API_KEY"] for attempt in range(3): request = urllib.request.Request( url, headers={"Authorization": f"Bearer {key}"}, method="GET", ) try: with urllib.request.urlopen(request, timeout=30) as response: if not 200 <= response.status < 300: raise RuntimeError(f"HTTP {response.status}") return json.load(response) except urllib.error.HTTPError as error: body = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 2: raise RuntimeError(f"HTTP {error.code}: {body}") from error time.sleep(retry_delay(error.headers.get("Retry-After"), attempt)) raise RuntimeError("Discovery retry budget exhausted") if __name__ == "__main__": print(json.dumps(read_descriptor(), indent=2)) Schema inspection isn't a record mutation.
The example permits 3 attempts and sets each request timeout to 30 seconds. Those are sample policy choices, not service performance measurements or a total wall-clock deadline; honoring a rate-limit retry delay can extend the elapsed time.
The following Python program runs locally using only the standard library. It demonstrates the application boundary after a domain-add result has supplied a handle; it doesn't guess a provider response shape or issue a DNS request. Its fixture identifiers are illustrative. A production adapter would obtain the real handle from the selected provider's documented response.
import sqlite3 def bind_zone(db, tenant_id, domain_label, zone_id): if not zone_id: raise ValueError("A zone handle is required") with db: db.execute( "INSERT INTO bindings VALUES (?, ?, ?)", (tenant_id, domain_label, zone_id), ) def prepare_record_change(db, tenant_id, inventory_zone_ids): row = db.execute( "SELECT zone_id FROM bindings WHERE tenant_id = ?", (tenant_id,), ).fetchone() if row is None: raise LookupError("Tenant has no saved zone binding") zone_id = row[0] if zone_id not in inventory_zone_ids: raise LookupError("Saved zone is absent from reconciled inventory") return zone_id def main(): with sqlite3.connect(":memory:") as db: db.execute( "CREATE TABLE bindings (" "tenant_id TEXT PRIMARY KEY, " "domain_label TEXT NOT NULL, " "zone_id TEXT NOT NULL)" ) bind_zone(db, "harbor-desk", "harbor.example.com", "demo-zone-a") inventory = {"demo-zone-a"} print(prepare_record_change(db, "harbor-desk", inventory)) try: prepare_record_change(db, "harbor-desk", set()) except LookupError as error: print(error) if __name__ == "__main__": main() Notice that the record-change preparation function accepts a tenant ID, resolves the saved binding locally, and returns the zone handle. The inventory argument represents a reconciliation result already obtained by the caller. It isn't an instruction to fetch the zone list for every mutation, and the example's in-memory database is a demonstration rather than durable storage.
The remaining race deserves an explicit boundary: a zone may disappear after reconciliation and before the record request. The adapter must still check the actual operation's response and surface its reason for failure. A saved handle eliminates repeated identity lookup; it cannot make an earlier inventory observation permanently true. Keep that error associated with the binding, without interpreting it as evidence about a recipient's mailbox or retrying a newsletter send because a DNS preparation step failed.
Reject repeated lookup for the provisioning path
The rejected option is resolving the domain name into a zone handle before every record change. It avoids persisting a field, but puts an extra remote read on the critical path and spends rate-limit capacity on identity lookup. It also makes a tenant's displayed name part of resource selection. For automatic subdomain assignment, accept the stored binding and its reconciliation responsibility.
Name-based discovery still has a valid use case: an administrative inventory task that begins with a domain name and has no saved binding. Use it to establish or review the association, then persist the confirmed handle before enabling tenant automation. Don't silently rebind an existing tenant on a name match.
For Harbor Desk, the acceptance evidence is deliberately narrow. A saved zone handle establishes where a record operation should go. A reconciliation result establishes what inventory contained when observed. DMARC results and reports concern message authentication and alignment; they do not promise inbox placement. Keeping those claims separate gives the communications backend an explanation for its next action, rather than a single optimistic status that conceals which prerequisite was checked.
References
- DMARC authentication, alignment, and reporting: https://datatracker.ietf.org/doc/html/rfc7489
- Cloudflare DNS documentation for reviewing its management contract: https://developers.cloudflare.com/dns/
- Amazon Route 53 API reference for reviewing hosted-zone and record operations: https://docs.aws.amazon.com/Route53/latest/APIReference/Welcome.html
- Google Cloud DNS documentation for reviewing managed-zone and record-set operations: https://cloud.google.com/dns/docs


