# records.set()

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

`domain.records.set({ type, name, content, priority?, ttl?, replace? }) → Promise<Record>`

Writes a record: it replaces the one with the same type and name, or creates it. The types that legitimately repeat are handled differently.

Status: PUT · replace or create · NS refused

```javascript
await domain.records.set({ type: "CNAME", name: "docs", content: "example.pages.dev" });
await domain.records.set({ type: "MX", name: "@", content: "mx.example.net", priority: 10 });
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `type` | string | required | `A`, `AAAA`, `CNAME`, `TXT`, `MX`, `SRV`, `CAA`. **`NS` is refused.** |
| `name` | string | required | Relative to the zone. `@` for the apex. |
| `content` | string | required | The value. |
| `priority` | number |  | `MX` and `SRV`. |
| `ttl` | number |  | Seconds. Automatic by default. |
| `replace` | boolean |  | Replace every record of that type and name, not only the matching one. |

## Some types legitimately repeat {#repeating}

> **MX, TXT and CAA can coexist on one name**
>
> So only the one with the same content is replaced — otherwise writing a second mail server would delete the first. Pass replace: true when you genuinely mean « this name now has exactly this ».

## NS is refused {#ns}

A record delegating a name away is exactly what a subdomain takeover looks like. The type is not accepted, with no option to force it.

## A record cannot leave the zone {#inside}

Names are relative, so there is no way to write into a zone that is not this one.

## A record does not make a name serve {#serving}

For a hostname that must actually answer, [serve()](/sdk/ref/domain/serve) writes the record *and* registers the name. A record alone gives an address that resolves and refuses.

- [records.remove()](/sdk/ref/domain/records/remove): Taking one out.
- [serve()](/sdk/ref/domain/serve): When it must answer.

```python
domain.records.set({"type": "CNAME", "name": "docs", "content": "example.pages.dev"})
domain.records.set({"type": "MX", "name": "@", "content": "mx.example.net", "priority": 10})
```
