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

# Responses and pagination

> Read JSON responses, handle errors, and follow pagination cursors.

## Read the response

Most reads return JSON. For example, `GET /profiles` returns an array in `data`, and `GET /profiles/{profile}` returns a single object in `data`. Analytics and logs can also include `meta` for pagination, time series, or streaming.

[Stream logs](https://docs.nextdns.io/api-reference/logs/stream.md) returns server-sent events. [Download logs](https://docs.nextdns.io/api-reference/logs/download.md) redirects to a CSV download by default. A `204 No Content` response has an empty body.

## Handle errors

Check both the HTTP status and the response body. Some operations return `200 OK` with an `errors` array when NextDNS declines a change. For example, adding an entry that already exists in the Denylist returns this body.

```json theme={null}
{
  "errors": [{ "code": "duplicate" }]
}
```

| HTTP status | When it can occur |
| - | - |
| `200` with `errors` | The request is valid, but the requested change cannot be applied. |
| `400` | A query parameter or request body fails validation. |
| `403` | `authRequired` means the profile request has no valid credentials. `insufficientRole` means your profile role does not permit the operation. |
| `404` | The resource does not exist or the account cannot access the profile. |
| `413` | `contentTooLarge` means the JSON body of a profile write exceeds 1 MiB (1,048,576 bytes). |
| `429` | `rateLimit` means a [request limit](#rate-limits) was exceeded. Back off before retrying. |
| `504` | `timeout` means the server timed out before it could send a response. |

Read `errors[].code` for the reason. Validation errors can include a `detail` message and identify the offending query parameter in `source.parameter` or body field in `source.pointer`.

## Fetch the next page

For paginated analytics and historical log queries, pass `meta.pagination.cursor` as the `cursor` query parameter on the next request. Treat it as an opaque string and keep the endpoint, sort order, and filters the same. Stop when there is no next cursor. An oldest-first raw log query can return the same cursor while waiting for new entries. See [List logs](https://docs.nextdns.io/api-reference/logs/list.md).

For example, to fetch the next page of logs after a request with `limit=50`, set `CURSOR` to the value from the previous response and repeat the request.

```bash theme={null}
curl -sS --get "https://api.nextdns.io/profiles/$PROFILE_ID/logs" \
  -H "X-Api-Key: $NEXTDNS_API_KEY" \
  --data-urlencode 'limit=50' \
  --data-urlencode "cursor=$CURSOR"
```

## Rate limits

Requests to an individual profile share a limit of 300 reads and 60 writes per minute across callers. Account-wide limits also apply across profiles and depend on your subscription. Streaming and downloading logs have additional limits.


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