> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextdns.io/llms.txt
> Use this file to discover all available pages before exploring further.

# DNS rewrites

> Give a hostname a custom IPv4 address, IPv6 address, or CNAME for one profile.

## Add a rewrite

Send a lowercase ASCII hostname in `name` and the desired answer in `content`. Use Punycode for internationalized names. NextDNS creates an `A` record for an IPv4 address, an `AAAA` record for an IPv6 address, or a `CNAME` for a hostname.

```bash theme={null}
curl -X POST "https://api.nextdns.io/profiles/$PROFILE_ID/rewrites" \
  -H "X-Api-Key: $NEXTDNS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"printer.example.com","content":"192.0.2.10"}'
```

The response includes the rewrite ID.

```json theme={null}
{
  "data": {
    "id": "rw123abc",
    "name": "printer.example.com",
    "type": "A",
    "content": "192.0.2.10"
  }
}
```

A hostname can have several different address records, or a single CNAME. Adding a duplicate answer or combining an address and a CNAME for the same hostname returns HTTP `200` with an error code of `conflict`.

Each profile supports up to 500 rewrites. Going over the limit returns HTTP `400` with `{"code":"listLimitExceeded","list":"rewrites","limit":500}` in the `errors` array.

## List or remove rewrites

`GET /profiles/{profile}/rewrites` returns a `data` array containing all the profile's rewrites.

```bash theme={null}
curl "https://api.nextdns.io/profiles/$PROFILE_ID/rewrites" \
  -H "X-Api-Key: $NEXTDNS_API_KEY"
```

To remove one, set `REWRITE_ID` to the `id` from the list or creation response. A successful deletion returns `204 No Content`. An unknown ID returns `404 Not Found`.

```bash theme={null}
curl -X DELETE "https://api.nextdns.io/profiles/$PROFILE_ID/rewrites/$REWRITE_ID" \
  -H "X-Api-Key: $NEXTDNS_API_KEY"
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.