> ## 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.

# Allowlist and Denylist

> Allow, block, or temporarily disable an entry for a domain and its subdomains.

Each profile has an Allowlist and a Denylist. Both accept the same requests. An active entry applies to the domain itself and all of its subdomains. For example, `example.com` also matches `www.example.com`. If a domain matches both lists, the Allowlist takes precedence. To block an entire top-level domain, add its bare name, such as `zip`, to the Denylist.

## Read a list

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

```json theme={null}
{
  "data": [
    { "id": "example.com", "active": true },
    { "id": "zip", "active": false }
  ]
}
```

`GET` returns the complete list, newest entries first, including inactive entries. To read the Allowlist, change `denylist` to `allowlist`.

## Add an entry

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

Send `id` as a lowercase ASCII domain. Omit leading dots and wildcards. Use Punycode for internationalized names. The optional boolean `active` defaults to `true`. All successful writes on these endpoints return `204 No Content`.

Adding an existing ID returns HTTP `200` with an `errors` array containing `{"code":"duplicate"}`. To change an existing entry, use `PATCH`.

## Disable or remove an entry

To keep an entry in the list and pause its effect, set `active` to `false`. Send `true` to enable it again.

```bash theme={null}
curl -X PATCH "https://api.nextdns.io/profiles/$PROFILE_ID/denylist/example.com" \
  -H "X-Api-Key: $NEXTDNS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"active":false}'
```

To remove it altogether, send `DELETE` to the same URL.

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

Updating or deleting an ID that does not exist returns `404 Not Found`.

## Replace a list

`PUT` takes the full array of entries. It removes every existing entry omitted from the request, including inactive entries. Sending `[]` clears the list.

```bash theme={null}
curl -X PUT "https://api.nextdns.io/profiles/$PROFILE_ID/allowlist" \
  -H "X-Api-Key: $NEXTDNS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[{"id":"example.com","active":true},{"id":"example.org","active":false}]'
```

Each profile can store **5,000 entries per list**, including inactive entries. If a write would exceed the entry limit, the API returns HTTP `400` and keeps the existing list.

```json theme={null}
{
  "errors": [
    { "code": "listLimitExceeded", "list": "allowlist", "limit": 5000 }
  ]
}
```

The JSON request body can be up to 1 MiB. A larger replacement returns HTTP `413` with `contentTooLarge`, even if the entry count is within the limit.


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