# Exports

Le rapport PDF et le classeur Excel d’un crawl, générés en tâche de fond.

## Demander l’export d’un crawl

`POST /v1/crawls/{crawl}/exports`

Met en file le rapport PDF ou le classeur Excel d’un crawl terminé et répond `202` avec l’export à sonder (`Location`). L’Excel exige une offre qui l’inclut (`plan_limit.exports.excel`). Un export identique encore en cours est rendu au lieu d’en lancer un second.

- Scopes requis: `exports:write`
- Coût en débit: 10 unité(s)
- Idempotency-Key acceptée

### Paramètres

- `crawl` (path, string (uuid), requis)

### Corps de la requête

- `format` (string, requis) [pdf, xlsx]

### Réponses

- `202`: OK.
- `400`: Malformed request, such as an invalid pagination cursor (`pagination.invalid_cursor`).
- `401`: Missing, invalid or expired token, or a member who left the team.
- `403`: The plan does not include the API (`api.not_in_plan`) or this verb
(`api.write_not_in_plan`), or the token lacks a scope
(`token.missing_scope`).

- `404`: No such resource for the token's team. Resources of another team answer 404 as well, never 403.
- `409`: The request conflicts with the current state (a crawl already running, an idempotency key in use, a project not ready).
- `422`: Invalid query or body values (`validation_failed`), with `errors` by field.
- `429`: The plan rate limit is exhausted for one window.

### Exemple de requête (cURL)

```bash
curl -X POST "https://api.nessflow.com/v1/crawls/0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57/exports" \
  -H "Authorization: Bearer $NESSFLOW_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"format":"pdf"}'
```

### Exemple de réponse

```json
{
    "data": {
        "id": "0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57",
        "crawl_id": "0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57",
        "format": "pdf",
        "status": "queued",
        "size_bytes": 42,
        "download_url": "https://exemple.fr/",
        "created_at": "2026-10-01T09:30:00Z",
        "finished_at": "2026-10-01T09:30:00Z",
        "expires_at": "2026-10-01T09:30:00Z"
    }
}
```

## Lire un export

`GET /v1/exports/{export}`

L’état d’un export. Quand `status` vaut `ready`, `download_url` est renseigné jusqu’à `expires_at`.

- Scopes requis: `crawls:read`
- Coût en débit: 1 unité(s)

### Paramètres

- `export` (path, string (uuid), requis)

### Réponses

- `200`: OK.
- `401`: Missing, invalid or expired token, or a member who left the team.
- `403`: The plan does not include the API (`api.not_in_plan`) or this verb
(`api.write_not_in_plan`), or the token lacks a scope
(`token.missing_scope`).

- `404`: No such resource for the token's team. Resources of another team answer 404 as well, never 403.
- `429`: The plan rate limit is exhausted for one window.

### Exemple de requête (cURL)

```bash
curl "https://api.nessflow.com/v1/exports/0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57" \
  -H "Authorization: Bearer $NESSFLOW_TOKEN"
```

### Exemple de réponse

```json
{
    "data": {
        "id": "0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57",
        "crawl_id": "0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57",
        "format": "pdf",
        "status": "queued",
        "size_bytes": 42,
        "download_url": "https://exemple.fr/",
        "created_at": "2026-10-01T09:30:00Z",
        "finished_at": "2026-10-01T09:30:00Z",
        "expires_at": "2026-10-01T09:30:00Z"
    }
}
```

## Télécharger un export

`GET /v1/exports/{export}/download`

Le fichier, en pièce jointe. `409 export.not_ready` pendant la génération, `410 export.expired` une fois supprimé.

- Scopes requis: `crawls:read`
- Coût en débit: 1 unité(s)

### Paramètres

- `export` (path, string (uuid), requis)

### Réponses

- `200`: OK.
- `401`: Missing, invalid or expired token, or a member who left the team.
- `403`: The plan does not include the API (`api.not_in_plan`) or this verb
(`api.write_not_in_plan`), or the token lacks a scope
(`token.missing_scope`).

- `404`: No such resource for the token's team. Resources of another team answer 404 as well, never 403.
- `409`: The request conflicts with the current state (a crawl already running, an idempotency key in use, a project not ready).
- `410`: The resource existed and has been removed (`export.expired`).
- `429`: The plan rate limit is exhausted for one window.

### Exemple de requête (cURL)

```bash
curl "https://api.nessflow.com/v1/exports/0190f5a2-7c4e-7b1a-9d3e-2f6b8c1a4e57/download" \
  -H "Authorization: Bearer $NESSFLOW_TOKEN"
```
