# add()

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

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

附加域名并将其交给登记员。 区域开始空空, 没有任何文字 。

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
```

## 区域开始空空, 这就是陷阱 {#empty}

> **暂时不要告诉客户切换**
>
> 在别处购买的域名已经服务于网站和邮箱。 指定空区登记员, 此时停止所有域名。 首先读取迁移( ) , 如果它这么说, 则导入( ) 。

## 附加触发读而非写 {#search}

搜索域域今天服务的内容, 搜索附加在附加上, 并查找它找到的种子 [(移徙)](/zh/sdk/ref/domain/migration) 和 [( 导入)](/zh/sdk/ref/domain/records/import)。无任何东西出现在该区。

## 整个序列 {#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();
```

## 名字属于一个账户 {#once}

`domain_taken` 第二次尝试:第二个账户将覆盖第一个区域。

## 读取命名者, 不要硬码他们 {#nameservers}

它们被存储在每个域域, 并返回到对象上。 将一对书写入自己的代码是有效的, 直到它不起作用的一天。

- [migration()](/zh/sdk/ref/domain/migration): 安全换位了吗?
- [check()](/zh/sdk/ref/domain/check): 开关发生了吗?
- [域域域域域](/zh/sdk/ref/domain): 域能带来什么,你能做些什么。

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