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

# Download logs

> Export all retained DNS queries for a profile to a CSV file.

The export contains individual queries in reverse chronological order. It covers the profile’s full retained history and includes the details recorded under its logging settings. For a filtered time range or a single device, use [List logs](https://docs.nextdns.io/api-reference/logs/list.md).

In the CSV, a blank `status` corresponds to `default` in the JSON logs. An export with zero entries produces an empty file.

**profile** `string` *required*

Profile ID.

**redirect** `boolean` (default: true)

By default, the API responds with `302 Found` and a download URL in the `Location` header. Pass `0` or `false` to receive `200 OK` with the URL in `data.url` once the export is ready.

Anyone with the download URL can retrieve the exported file. Store it with the same care as the logs themselves.

```bash Download CSV theme={null}
curl --fail --location "https://api.nextdns.io/profiles/$PROFILE_ID/logs/download" \
  --header "X-Api-Key: $NEXTDNS_API_KEY" \
  --output "${PROFILE_ID}.csv"
```

```bash Get download URL theme={null}
curl "https://api.nextdns.io/profiles/$PROFILE_ID/logs/download?redirect=0" \
  --header "X-Api-Key: $NEXTDNS_API_KEY"
```

```json 200 theme={null}
{
  "data": {
    "url": "https://api.nextdns.io/logs/c2ke6y/<export-token>"
  }
}
```


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