# add()

Canonical URL: https://developers.iagenify.com/sdk/ref/domains/add/
Language: en

`api.domains.add(name) → Promise<Domain>`

Attaches a domain and hands back the nameservers to set at the registrar. The zone starts empty, and nothing is written.

Status: writes nothing · one account per name · nameservers come back

```javascript
const domain = await api.domains.add("example.com");

domain.status;        // "pending_nameservers"
domain.nameservers;   // the pair to set at the registrar
```

## The zone starts empty — and that is the trap {#empty}

> **Do not tell the customer to switch yet**
>
> 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 {#search}

A search of what the domain serves today runs on attach, and what it finds feeds [migration()](/sdk/ref/domain/migration) and [import()](/sdk/ref/domain/records/import). Nothing is posed in the zone.

## The whole sequence {#sequence}

```javascript
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();
```

## A name belongs to one account {#once}

`domain_taken` on a second attempt: the second account would overwrite the first one's zone.

## Read the nameservers, do not hardcode them {#nameservers}

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.

- [migration()](/sdk/ref/domain/migration): Is switching safe yet?
- [check()](/sdk/ref/domain/check): Has the switch happened?
- [Domain](/sdk/ref/domain): What a domain carries, and what you can do to it.

```python
domain = api.domains.add("example.com")

domain.status        # "pending_nameservers"
domain.nameservers   # the pair to set at the registrar
```

```python
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()
```
