---
title: "Export logs"
url: https://docs.corefinity.com/api/recipes/export-logs
type: page
last_updated: 2026-11-13
feature: recipe-export-logs
---
# Export logs

Start an export of a site's log lines, read it until the file is ready and collect the file.

An export makes a file of the log lines that match, up to 50,000 lines or 64 MiB. This recipe exports the last day of web requests to the site `harbourandfinch.example.com` as CSV.

## Before you start

- A token with the `read` [scope](/api/scopes), and a person who can see the site's logs.
- Every step needs [two-factor enrolment](/api/two-factor) when your company requires it.
- No step waits for a maintenance window.

1. **Start the export**

   Send the `format` (`csv`, or `json` for one JSON object a line), the `source` to read and how far back to read. `GET /corestack/sites/{site}/logs/streams` lists the sources; a `query` narrows the lines.

   ```bash
   curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/logs/exports \
     -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"format": "csv", "source": "web-access", "range": "24h"}'
   ```

   The answer is `202` with the export to follow, in `download`, and its `capability`. Note `download.id`, and keep the `capability`: it is shown only this once, and step 3 needs it.

2. **Read the export**

   Read the export every few seconds until its `state` is `ready`. Only the person who started an export can read it.

   `failed` and `expired` are final too: start a new export.

   ```bash
   curl https://manage.corefinity.com/api/corestack/logs/exports/01JB2Y8N7Q4X3R5T6V8W9Z0A1B \
     -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json"
   ```

   `lines` and `bytes` say how large the file is, and `truncated` is `true` when it was cut at the limit.

3. **Collect the file**

   Send the `capability` within 24 hours. The answer is `200` with the file itself, not a JSON document.

   > **Warning:** The file can be collected once. Collecting it removes the export: a second request answers `410`, and so does a request after the 24 hours.

   ```bash
   curl -X POST https://manage.corefinity.com/api/corestack/logs/exports/01JB2Y8N7Q4X3R5T6V8W9Z0A1B/collect \
     -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"capability": "Example-export-capability-0000000000000000000001"}' \
     -o harbourandfinch-web-access.csv
   ```

## If it is refused

| Status | `reason`                                | What to do                                                                                                                                     |
| ------ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `404`  | `feature_off`                           | Logs are not on for your company                                                                                                               |
| `422`  | `invalid`                               | Correct the field named in `field` and `errors`. On `capability`: it is missing or is not this export's; nothing is used up                    |
| `409`  | `logs_not_collected`                    | Logs are not collected for this environment yet                                                                                                |
| `409`  | `logs_range`                            | `from` is before the time your logs are kept for. Choose a later start                                                                         |
| `409`  | `query_too_wide`                        | Add a `source` or narrow the time range                                                                                                        |
| `409`  | `download_preparing`                    | The export is still being prepared. Do step 2 until `state` is `ready`                                                                         |
| `410`  | `expired`                               | The export was collected already, has expired or failed. Start a new one                                                                       |
| `503`  | `logs_busy`, `logs_cluster_unavailable` | The logs store is busy or did not answer. The request itself is fine: try again shortly                                                        |
| `429`  | `rate_limited`                          | Starting and collecting share a budget of 5 requests in 10 minutes. Wait for the seconds in `Retry-After`; see [Rate limits](/api/rate-limits) |
