const domain = await api.domains.add("example.com");
domain.status; // "pending_nameservers"
domain.nameservers; // the pair to set at the registrardomain = api.domains.add("example.com")
domain.status # "pending_nameservers"
domain.nameservers # the pair to set at the registrarThe zone starts empty — and that is the trap
A domain bought elsewhere already serves a site and mailboxes. Pointing the registrar at an empty zone stops all of it at that second. Read migration() first, and import() if it says so.
Attaching triggers a read, not a write
A search of what the domain serves today runs on attach, and what it finds feeds migration() and import(). Nothing is posed in the zone.
The whole sequence
const domain = await api.domains.add("example.com");
const plan = await domain.migration();
if (!plan.safeToSwitch) {
const { added, skipped } = await domain.records.import();
console.log(added, "copied,", skipped.length, "to do by hand");
}
// Now the registrar can be pointed at domain.nameservers
await domain.check();domain = api.domains.add("example.com")
plan = domain.migration()
if not plan["safeToSwitch"]:
result = domain.records.import_zone()
print(result.get("added"), "copied,", len(result.get("skipped") or []), "to do by hand")
# Now the registrar can be pointed at domain.nameservers
domain.check()A name belongs to one account
domain_taken on a second attempt: the second account would overwrite the first one's zone.
Read the nameservers, do not hardcode them
They are stored per domain and come back on the object. Writing a pair into your own code is the kind of thing that works until the day it does not.