const records = await domain.records.list();
const stale = records.find((r) => r.type === "CNAME" && r.name === "old");
if (stale) await domain.records.remove(stale.id);records = domain.records.list()
stale = next((r for r in records if r["type"] == "CNAME" and r["name"] == "old"), None)
if stale:
domain.records.remove(stale["id"])By identifier, deliberately
Several records can share a type and a name — mail servers, text records. Removing « the MX at the apex » would be ambiguous, and the ambiguity would be resolved by guessing. Listing first and removing a specific one is the shape that cannot delete the wrong thing.
What a removal does
| Removing | Stops |
|---|---|
| An address or alias record | The site at that name. |
| A mail record | Mail arriving. Nothing appears broken. |
| The signing key | Messages being verifiable — including ones already sent. |
| The policy | What receivers do with misaligned mail. |
For mail, prefer disable()
mail.disable() removes only what we posed, leaves the customer's own records alone, and keeps the signing key. Removing mail records one at a time does none of that.
Resolvers keep it briefly
A record lives in caches for its lifetime. The name can keep answering after this returns.