# preview_dns_records

Source: https://modulify.ai/docs/mcp/bought-domains/preview-dns-records

Checks what a set of DNS records would do to a domain the workspace bought, without changing anything.

- Title: Preview a set of DNS records for a bought domain
- Scope: `domains:read`
- Access: Read only

Send up to 20 records, of any type `create_dns_record` takes: A, AAAA, ANAME, CNAME, MX, NS, SRV or TXT. Nothing is saved.

The answer carries `DomainId`, `WorkspaceId`, `WorkspaceName`, `Name`, `State`, `UsesProviderDns`, `CanManage`, `CanApply`, `Refusal` and `Records`, one entry per record in the order sent. Each entry carries `Index`, `Type`, `Host`, `Fqdn`, `Value`, `Ttl`, `Priority`, `Weight`, `Port`, `Action`, `Replaces` and `Reason`.

| `Action` | Meaning |
| --- | --- |
| `add` | The record would be added |
| `keep` | A record with the same name, type and value, and for MX and SRV the same priority, already exists, so nothing would change. Its TTL stays as it is |
| `replace` | The records in `Replaces` would be deleted to make room for it. They are listed the way `list_dns_records` lists them, each with the `Id` that `apply_dns_records` takes in `replaceRecordIds` |
| `blocked` | The record cannot be added, and `Reason` says why |

A record is only ever added unless it was sent with `replace` set to `true`. With it, the record takes the place of the records at its name that it clashes with:

- Every other record, for a CNAME record.
- The A, AAAA and ANAME records, for an A, AAAA or ANAME record.
- The other MX records, for an MX record.
- The other SRV records, for an SRV record.
- The SPF record, for an SPF record.
- A CNAME record at that name, for every type.

An NS record replaces nothing and is never replaced, so it follows the rules of `create_dns_record` whatever `replace` says, and a record at or under a name that an NS record hands to other nameservers stays blocked. A record of the set that already exists is kept, never deleted. Without `replace`, a record that cannot exist next to one already there is blocked, by the rules `create_dns_record` follows.

Records Modulify manages for a site or an email domain of the workspace, the ones `list_dns_records` shows with `Locked` true, are never replaced, and a record that would clash with one is blocked with that site or email domain named. The same record twice in one set is blocked, and so is a record without a `host`.

`CanApply` is true when `apply_dns_records` would save the whole set, and `Refusal` says why not. One blocked record blocks them all, and so does a missing **Manage domains** permission, which `CanManage` reports, or a domain that is not `active` or `expiring`. When `UsesProviderDns` is false the set can still be saved, but other nameservers answer for the domain.

A domain can be previewed while `active`, `expiring` or `expired`, by every member of the workspace, 20 times a minute per person across every domain, shared with `list_dns_records`. See [Add records with a link](https://modulify.ai/docs/publish/add-records-with-a-link).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `workspaceId` | string | Yes | The workspace that owns the domain. |
| `domainId` | string | Yes | The `_id` of the bought domain, from `list_bought_domains`. |
| `records` | array of objects | Yes | The records. Each takes `type` (`A`, `AAAA`, `ANAME`, `CNAME`, `MX`, `NS`, `SRV` or `TXT`), `host` and `value`, which are required, and `priority`, `weight`, `port`, `ttl` and `replace`. The fields mean what they mean on `create_dns_record`, and `replace` is `true` to let the record take the place of the records it clashes with. |