# Exporter un rapport

> Demander le rapport PDF ou le classeur Excel d’un crawl, attendre qu’il soit prêt et le télécharger.

Un export se génère en tâche de fond, en trois temps : demander, attendre, télécharger.

## Demander

```bash expect=202
curl -X POST "https://api.nessflow.com/v1/crawls/$CRAWL_ID/exports" \
  -H "Authorization: Bearer $NESSFLOW_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"format": "pdf"}'
```

`format` vaut `pdf` (le rapport exécutif) ou `xlsx` (le classeur complet, si votre offre l’inclut). Un export identique encore en cours est rendu au lieu d’en lancer un second, et un crawl qui tourne encore est refusé (`409 export.crawl_not_finished`) : son rapport serait incomplet.

## Attendre

```bash
curl "https://api.nessflow.com/v1/exports/$EXPORT_ID" \
  -H "Authorization: Bearer $NESSFLOW_TOKEN"
```

Quand `status` vaut `ready`, `download_url` est renseigné jusqu’à `expires_at`. Un webhook `export.ready` évite de sonder.

## Télécharger

```bash
curl -o rapport.pdf "https://api.nessflow.com/v1/exports/$EXPORT_ID/download" \
  -H "Authorization: Bearer $NESSFLOW_TOKEN"
```

Le téléchargement exige le jeton, comme tout appel : un lien qui circulerait dans un message ne suffit pas. Un export expiré répond `410 export.expired` ; demandez-en un nouveau.
