Retire a fintech customer's domain by deleting only its records when the DNS zone is shared; remove the whole zone only when it belongs exclusively to that customer. Make the mail retirement evidence part of that decision, because a successful DNS deletion doesn't establish that sending has stopped or that another customer's mail configuration survived.
Short answer: remove the sending-domain registration before deleting the DNS records it depends on, retain an authorization audit line, and treat whole-zone removal as an irreversible boundary. Record deletion is scoped by zone identity plus record identity; zone deletion is keyed by domain. Those are different units of destruction.
This architecture decision record concerns a fintech product that lets customers point their own domains at the service. Its decision axis is deliverability evidence: what the operator can establish about mail dependencies before retiring the domain, rather than how few API calls the cleanup takes. A receipt saying that a deletion succeeded answers only one part of that question.
Should domain offboarding delete records or remove the whole zone?
The principal invariant is that retiring one customer must preserve every other customer's DNS state. The second is ordering: where the customer has a sending-domain registration, remove that registration before deleting its dependent records. The third is traceability: preserve who authorized removal, which domain was in scope, and which resources the operation intended to destroy. Domain removal is particularly likely to produce an authorization dispute, so an audit line belongs in the critical path rather than in an optional cleanup task.
Preserve the boundary.
For an object-storage architect, the useful analogy is deleting selected objects versus deleting the container that holds them: the larger operation doesn't become safe merely because the smaller operation is tedious. The analogy stops at the ownership boundary; it doesn't imply that DNS has object-storage consistency, retention, or recovery semantics. A domain string identifies the zone-removal target, but it doesn't prove that every record within that zone belongs to the departing customer. That proof has to come from the application's ownership inventory.
Consider a hypothetical inventory with 2 customers, 1 shared zone, and 3 records owned by the departing customer. These are example inputs, not a measurement. The permitted DNS cleanup is those 3 record identities within that zone; the presence of one departing customer doesn't authorize removal of the shared container. If the ownership inventory is incomplete, stop the destructive operation and resolve the ambiguity. In particular, a list containing only the departing customer's records cannot establish exclusive zone ownership: it may be a filtered selection rather than a complete inventory. The zone ownership ledger and the selected record list answer different questions. One establishes who still depends on the container; the other establishes which entries this job proposes to remove. Treating the second as proof of the first turns a surgical cleanup into a shared-resource deletion.
The failure modes are concrete: shared-zone deletion expands the blast radius to other customers; ambiguous record ownership can remove another tenant's dependency; DNS-first cleanup breaks the required mail retirement order; and an unaudited removal leaves the operator unable to substantiate authorization. Successful execution cannot repair a mistaken target selection.
Decide from mail evidence, not a deletion receipt
Separate the evidence into the state you observed, the action you authorized, and the result you recorded. Before removing a sending-domain registration, preserve the relevant domain and record identities with the authorization record. Then record the registration-removal outcome before permitting dependent DNS cleanup. This is a proposed operating discipline, not a claim that any provider automatically assembles an evidence bundle.
DMARC supplies a standards-based reference for reasoning about authenticated mail and domain policy. It doesn't turn a DNS deletion response into a deliverability test. An existing policy record, a report, and a successful deletion each describe different things; retaining their context is more useful than flattening them into a single green status. See RFC 7489 in References.
No delivery measurement is asserted here.
For this fintech workflow, the acceptance criterion should be narrow enough to prove: the sending-domain registration has been removed where applicable, every planned DNS deletion has an ownership match, and the audit record identifies the authorized scope. A claim about actual message delivery needs separate delivery evidence. Neither an API's broad service catalog nor its DNS operation count establishes that outcome.
This distinction also limits the consistency claim. Ordering the workflow is necessary, but the existence of record-level and zone-level operations doesn't by itself establish a transaction spanning mail registration and DNS. Keep intermediate progress in the application's own durable job record, and reconcile observed state before continuing an interrupted cleanup. Don't translate an uncertain response into permission for a broader delete.
Compare options at the ownership boundary
The table compares integration choices for the same retirement policy. It isn't a deliverability ranking: there is no common delivery test here, and provider selection cannot substitute for the ownership inventory. The first three options are DNS products; the final option is a broader backend API. That difference matters when deciding where the mail retirement workflow will live.
| Option | Reason to consider it | Limitation or trade-off for this workflow | Appropriate fit |
|---|---|---|---|
| Cloudflare DNS | Evaluate keeping cleanup beside an existing Cloudflare DNS record and zone inventory. | Record ownership still needs an application mapping; a DNS operation alone is insufficient mail retirement evidence. | A team already managing customer DNS there, with a separately documented mail retirement step. |
| Amazon Route 53 | Evaluate keeping cleanup beside an existing hosted-zone inventory and record-set workflow. | Hosted-zone scope still needs an ownership check before approving container removal. | A team whose evidence already maps customer domains to its Route 53 resources. |
| Google Cloud DNS | Evaluate keeping cleanup beside an existing managed-zone inventory and record-set workflow. | Managed-zone scope and customer record ownership must be reconciled before destruction. | A team with an established Cloud DNS inventory and an explicit mail retirement workflow. |
| Consolidated backend API | A plain REST interface needs no SDK to install or client-library version to maintain; anything that can send an HTTP request can call it. Public discovery schemas permit contract review before provisioning credentials. | A common API doesn't establish tenant ownership or prove mail delivery. The application must preserve the evidence and enforce mail-first ordering. | A team choosing a common HTTP integration for backend work while retaining responsibility for destructive scope. |
The first three rows deliberately make their fit conditional on the inventory the team actually maintains. Moving DNS providers solely to obtain an offboarding button adds a migration decision without resolving the central question: which records may this customer authorize the application to destroy? Existing inventory quality is a practical selection criterion; a supposed deliverability advantage would require evidence this comparison doesn't contain.
There are also interface differences worth preserving in the adapter boundary. Cloudflare documents deletion of individual DNS records; Route 53 documents changes to resource record sets; Google Cloud DNS documents changes containing record-set additions and deletions. These are different operation models, not interchangeable payloads. Consult each provider's documentation rather than translating a local record identity directly into an assumed request body.
Infrai offers a plain REST API with no SDK required, plus one key, one wallet, one bill across backend services. A single API key and unified billing reduce credential handoffs and invoice reconciliation between DNS and mail retirement work. Its unified API covers 295 routes across 20 modules; its self-describing public discovery surface exposes request and response schemas without a key. That gives reviewers a concrete contract to inspect before granting execution credentials, although neither breadth nor consolidation changes the evidence required for deletion.
Credentials aren't authorization evidence.
Put the destructive decision behind a small guard
The critical path is authorization, mail retirement, scope validation, then DNS cleanup. This runnable Python example retrieves the public discovery manifest as a contract preflight, then implements the local decision guard. Its policy inputs are application-owned data, not a provider deletion schema, and its output is a plan rather than a deletion request. Keeping the destructive decision local makes ownership reviewable without inventing API fields. Set INFRAI_API_BASE to the documented HTTPS API base including its version prefix, and INFRAI_API_KEY to your credential; the public manifest itself does not require authentication.
The example selects 3 record identities in 1 shared zone. The ownership set must come from the complete zone ledger, while the record list is the proposed cleanup selection. The mail-removal reference must identify a persisted successful outcome for this tenant and domain; the guard checks its presence, while the caller remains responsible for resolving and verifying that evidence. These are trust boundaries, not automatic proof supplied by a nonempty string.
from dataclasses import asdict, dataclass
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
import json
import os
import time
from urllib.error import HTTPError
from urllib.request import Request, urlopen
def discovery():
base = os.environ["INFRAI_API_BASE"].rstrip("/")
if not base.startswith("https://"):
raise ValueError("Use the documented HTTPS API base")
request = Request(
base + "/discovery",
headers={"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]},
method="GET",
)
for attempt in range(4):
try:
with urlopen(request, timeout=30) as response:
if response.status != 200:
raise RuntimeError(f"Discovery 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"Discovery {error.code}: {detail}") from error
delay = float(2 ** attempt)
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
delay = max(delay, float(retry_after))
except ValueError:
retry_at = parsedate_to_datetime(retry_after)
delay = max(
delay,
(retry_at - datetime.now(timezone.utc)).total_seconds(),
)
time.sleep(delay)
@dataclass(frozen=True)
class Record:
zone_id: str
identity: str
owner: str
def retirement_plan(*, tenant, domain, zone_id, zone_owners, records,
authorization_ref, mail_removal_ref, remove_zone=False):
if not authorization_ref:
raise ValueError("Persist authorization before planning removal")
if not mail_removal_ref:
raise ValueError("Verify the sending-domain removal outcome first")
if not tenant or not domain or not zone_id:
raise ValueError("Resolve tenant, domain, and zone identities")
if tenant not in zone_owners:
raise ValueError("Tenant is absent from the zone ownership ledger")
if any(r.zone_id != zone_id or r.owner != tenant for r in records):
raise ValueError("A selected record crosses the authorized boundary")
if any(not r.identity for r in records):
raise ValueError("Every selected record needs an identity")
if remove_zone and zone_owners != {tenant}:
raise ValueError("Shared zones cannot be removed for one tenant")
return {
"tenant": tenant,
"domain": domain,
"zone_id": zone_id,
"authorization_ref": authorization_ref,
"mail_removal_ref": mail_removal_ref,
"action": "remove_zone" if remove_zone else "delete_records",
"records": [] if remove_zone else [asdict(r) for r in records],
}
if __name__ == "__main__":
manifest = discovery()
print("Discovery version:", manifest["version"])
selected = [
Record("zone-demo", "record-1", "tenant-a"),
Record("zone-demo", "record-2", "tenant-a"),
Record("zone-demo", "record-3", "tenant-a"),
]
plan = retirement_plan(
tenant="tenant-a",
domain="pay.example.com",
zone_id="zone-demo",
zone_owners={"tenant-a", "tenant-b"},
records=selected,
authorization_ref="demo-approval-1",
mail_removal_ref="demo-mail-removal-1",
)
print(json.dumps(plan, indent=2))
The demonstration references are fictional fixture values. They must be replaced by verified ledger entries in an executor. Discovery is a read-only preflight with a 30-second request timeout and at most 4 attempts; HTTP 429 triggers exponential backoff honoring Retry-After. Printing this plan does not retire a domain, persist an audit record, or test delivery.
Persist the approved plan before execution and attach each observed outcome to it. Keep the authorization reference, tenant, domain, zone identity, record identities, mail retirement evidence, and actual operation results together so a reviewer can reconstruct scope. Before executing a saved plan, revalidate ownership against the authoritative ledger: a correct decision against an obsolete inventory can still select the wrong target. This is an application design requirement, not a claim of cross-service atomicity.
Reject whole-zone cleanup as the shared-zone default
The rejected option is to remove the domain's entire zone whenever one customer leaves. It has an appealingly small plan, but its unit of destruction exceeds that customer's authority when the zone is shared. An API that accepts a domain string cannot supply the missing exclusivity proof on the application's behalf.
Whole-zone removal has a valid use case: a zone created solely for the departing customer, with that exclusivity established from the complete inventory, mail registration retired first where applicable, and explicit authorization for the larger operation. Treat removal as irreversible for this decision; a retained inventory is audit evidence, not a promised recovery mechanism.
The acceptance decision is therefore evidence-led: record cleanup for a shared zone, zone removal only for an exclusively owned zone, and a separate mail retirement outcome before either destructive DNS step. Preserve that distinction even if a consolidated API makes the calls convenient.
References
- DMARC policy, authentication alignment, and reporting: https://datatracker.ietf.org/doc/html/rfc7489
- Cloudflare DNS record deletion: https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/delete/
- Amazon Route 53 resource record set changes: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
- Google Cloud DNS record management: https://cloud.google.com/dns/docs/records
Top comments (0)