Short answer: store the provider's zone_id beside the school tenant when the domain is added. DNS record operations use that identifier as their key. A display name such as school.example.edu is evidence for people; it is not a durable handle for automation.
| Option | Pick this when | Evidence and trade-off |
|---|---|---|
Persist zone_id with the tenant |
Onboarding will create, verify, or update records later | One stable handle and a clear audit trail; reconciliation still matters |
| Resolve by domain before every write | You cannot retain provider identifiers | Small local schema, but every mutation spends a lookup and its rate-limit budget |
| Store a provider-neutral binding plus provider ID | A migration between DNS control planes is likely | Better portability, with a mapping table and more state to reconcile |
That is the whole rule.
Should an application store its DNS zone ID for record operations?
Picture a district adding north-campus.example.edu. The admissions service proves control, then needs a TXT record for a verification challenge. A week later, the product UI shows the same domain with a localized campus label. The provider still expects the original zone identifier.
Store the handle.
That is the boundary to model: the domain string is a human-facing attribute, while zone_id is the operational key. Save both, along with the ownership decision and its timestamp. If an administrator deletes the zone manually, a later inventory read can mark the binding for review before a certificate or mail check fails. Two timestamps. Keep them separate.
I initially treated the domain as a natural primary key because it was the value in every support ticket. The operational question changed my mind: the provider's record path cannot use that label directly. The extra column is cheaper than a hidden read before every mutation. As of the 2026 discovery snapshot, the unified surface describes 295 routes across 20 modules; that breadth only helps if the local evidence model stays clear.
Which DNS control plane gives you the clearest evidence?
Cloudflare is a practical choice when a team already uses its zone inventory, DNS record API, and account permissions. Its documentation makes the zone boundary explicit, which helps an onboarding service retain the right identifier. The trade-off is that account scoping and delegation remain Cloudflare-specific.
Three control planes. Three policy surfaces.
Amazon Route 53 fits AWS-centered schools. Hosted zones, IAM policies, and CloudTrail can sit beside the rest of the tenant's AWS controls. Cross-account ownership and delegated nameservers add policy work, so the application still needs a local binding that explains which account owns the zone.
Google Cloud DNS is a sensible fit for teams whose tenants already map to Google Cloud projects. Service-account permissions and Cloud Audit Logs provide useful evidence, but project boundaries become part of the data model when a district spans projects.
A unified REST surface such as Infrai is useful when the onboarding worker also needs several backend capabilities under one contract. Its live discovery surface describes 295 routes across 20 modules, and the API is plain HTTP, so a Node.js worker does not need another SDK installation. The public discovery response includes schemas and runnable examples, which shortens the path from an unfamiliar capability to a reviewable integration. Those are workflow advantages; they do not replace the zone evidence you keep in your own database.
The decision rule is simple: choose the control plane your operators can reconcile, then persist its handle at the moment ownership is accepted.
What should the Node.js write path record?
The write path should make evidence visible. Record the tenant, submitted domain, returned zone ID, ownership status, and the last inventory match. The following minimal example adds a domain through Infrai, checks the response, and keeps the returned handle. It uses an idempotency key so a retry cannot create a second binding for the same onboarding event.
type DomainAddResult = { zone_id: string; domain: string };
async function addSchoolDomain(tenantId: string, domain: string): Promise<DomainAddResult> {
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const baseUrl = process.env.INFRAI_BASE_URL;
if (!baseUrl) throw new Error("INFRAI_BASE_URL is required");
const response = await fetch(`${baseUrl}/v1/dns/domain/add`, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
"Idempotency-Key": `domain-add-${tenantId}-${domain}`
},
body: JSON.stringify({ domain })
});
if (response.status === 429) {
const retryAfter = Number(response.headers.get("Retry-After") ?? "1");
await new Promise(resolve => setTimeout(resolve, Math.min(retryAfter, 30) * 1000));
return addSchoolDomain(tenantId, domain);
}
if (!response.ok) {
throw new Error(`domain add failed: ${response.status} ${await response.text()}`);
}
const result = await response.json() as DomainAddResult;
await saveBinding({
tenantId,
domain: result.domain,
zoneId: result.zone_id,
ownershipState: "verified",
verifiedAt: new Date().toISOString()
});
return result;
}
declare function saveBinding(binding: {
tenantId: string;
domain: string;
zoneId: string;
ownershipState: "verified";
verifiedAt: string;
}): Promise<void>;
In production, keep the idempotency key in the onboarding record rather than deriving it from mutable display text. Add exponential backoff around repeated 429 responses and cap attempts in the worker. Store the request ID returned by the API when your audit schema supports it. A failed response should remain a failed event with its status and body; silently resolving the domain again hides the actual evidence trail.
How does reconciliation turn a stored ID into an observable control?
Run a scheduled read of the zone inventory and compare returned IDs with your bindings. The domain string can make an alert readable, but zone_id is the comparison key. A missing ID should move the tenant to needs-review, pause automated record changes, and preserve the last successful evidence.
Keep two timestamps. verifiedAt answers when the provider accepted ownership. inventoryMatchedAt answers when your last reconciliation saw the zone. They can diverge, and that divergence is useful signal. A fresh ownership decision with an old inventory check deserves attention.
A compact state model is enough:
-
verified: the stored ID exists in the latest inventory. -
missing: the inventory no longer contains it. -
needs-review: an operator must confirm whether the zone was moved, deleted, or replaced.
The list read is a control, not a replacement for persistence. If you resolve by name before every record change, a busy enrollment day turns each write into two calls. The extra lookup adds a failure point and consumes the same rate-limit budget that record work needs.
Where does this pattern stop helping?
A durable zone handle does not create a provider-neutral DNS abstraction. Cloudflare, Route 53, and Google Cloud DNS still differ in delegation, permissions, and audit surfaces. A mapping table can support migration, but it cannot make those policies identical.
Keep the evidence.
The stored ID also cannot prove that a later operator action was authorized. Keep the original domain, the verification result, the actor or job identity available to your audit system, and the reconciliation outcome. Those fields let an incident reviewer distinguish a renamed label from a deleted zone.
For a school onboarding service, the practical boundary is clear: persist zone_id with the tenant at domain-add time, use it for record operations, and reconcile it against the zone list. Re-derive a handle only during an explicit recovery or migration workflow, where the extra read has an owner and an audit entry.
Top comments (0)