# serve()

Canonical URL: https://developers.iagenify.com/sdk/ref/domain/serve/
Language: en

`domain.serve({ name, pages }) → Promise<Served>`

Makes a hostname actually serve: it writes the record and registers the name with the platform that will answer. Both halves, together.

Status: both halves · pages from servers() · a record alone is not enough

```javascript
const servers = await api.domains.servers();

const served = await domain.serve({ name: "docs", pages: servers[0].name });
// { hostname, target, project, status, certificate, note }
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `name` | string | required | The hostname, relative to the zone — `docs`, `www`. |
| `pages` | string | required | What will serve it, from [servers()](/sdk/ref/domains/servers). |

## Why it is one call {#why}

> **A DNS record never makes a hostname serve anything**
>
> The platform on the other end must recognise the name as well, or its edge refuses the connection — which reads as an outage. Writing the record alone is the mistake this call exists to prevent.

## The certificate takes a moment {#certificate}

`certificate` comes back as its state. Until it is active the connection fails — a wait, not a fault. Check it before telling anyone the address works.

## For a host created here, use the host {#hosting}

[host.domains.attach()](/sdk/ref/host/domains/attach) is the one for something hosted on IaGenify. This one is for serving a name from something else on the account.

## Undoing it {#removing}

[unserve()](/sdk/ref/domain/unserve) removes both halves — the registration and the record.

- [unserve()](/sdk/ref/domain/unserve): Taking it back.
- [servers()](/sdk/ref/domains/servers): What can serve.

```python
servers = api.domains.servers()

served = domain.serve(name="docs", pages=servers[0]["name"])
# {"hostname", "target", "project", "status", "certificate", "note"}
```
