# domains.attach()

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

`host.domains.attach(name) → Promise<Domain>`

Serves this host at a domain of your own. The domain must be attached to the account — we only write in a zone we hold.

Status: POST · the domain must be attached · a new certificate

```javascript
await host.domains.attach("www.example.com");
```

## The domain must be attached first {#attached}

> **domain_not_attached, and that is the point**
>
> Serving a name means writing in its zone. We only write in a zone we hold — so the domain goes through api.domains.add() first, and its nameservers must point here.

## It does both halves {#both-halves}

The record, and the registration that makes the platform accept the name. A record alone gives an address that resolves and refuses — which is the same reason [domain.serve()](/sdk/ref/domain/serve) exists for things hosted elsewhere.

## A new name means a new certificate {#certificate}

It takes a moment, and until it is active the address refuses the connection. Read `certificate` on the host before telling anyone the address works.

## Several names, one host {#several}

```javascript
await host.domains.attach("example.com");
await host.domains.attach("www.example.com");
```

Each gets its own record and its own certificate. The host's own address keeps working alongside them.

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| domain_not_attached | 409 | The domain is not on this account. |
| invalid_name | 400 | Not a usable hostname. |

- [domains.list()](/sdk/ref/host/domains/list): What is attached.
- [api.domains.add()](/sdk/ref/domains/add): Attaching the domain first.

```python
host.domains.attach("www.example.com")
```

```python
host.domains.attach("example.com")
host.domains.attach("www.example.com")
```
