# Documents

## GET `/documents`

**Lister les documents d’un projet**

Métadonnées seulement : le fichier se télécharge depuis Portal.

Demande une clé d’API avec la portée `portal:read`.

### Paramètres de requête

| Champ        | Type    | Obligatoire | Description                          |
| ------------ | ------- | ----------- | ------------------------------------ |
| `project_id` | string  | Oui         | Identifiant Portal.                  |
| `limit`      | integer | Non         | Par défaut : `20`. min. 1, max. 100. |
| `cursor`     | string  | Non         |                                      |

### Réponses

| Code  | Description              | Corps     |
| ----- | ------------------------ | --------- |
| `200` | Succès                   | `objet`   |
| `400` | Requête invalide         | `Problem` |
| `401` | Authentification requise | `Problem` |
| `403` | Accès refusé             | `Problem` |
| `429` | Trop de requêtes         | `Problem` |
| `500` | Erreur interne           | `Problem` |

### Champs de la réponse `200`

| Champ                 | Type                   | Description                                                      |
| --------------------- | ---------------------- | ---------------------------------------------------------------- |
| `data`                | objet\[]               |                                                                  |
| `data[].id`           | string                 | Identifiant Portal.                                              |
| `data[].object`       | string                 |                                                                  |
| `data[].project_id`   | string                 | Identifiant Portal.                                              |
| `data[].title`        | string                 |                                                                  |
| `data[].file_name`    | string                 |                                                                  |
| `data[].content_type` | string                 |                                                                  |
| `data[].size`         | integer                | Taille en octets. min. -9007199254740991, max. 9007199254740991. |
| `data[].sha256`       | string                 |                                                                  |
| `data[].visibility`   | “internal” \| “shared” |                                                                  |
| `data[].from_client`  | boolean                |                                                                  |
| `data[].created_at`   | string                 | Date et heure ISO 8601 (UTC).                                    |
| `next_cursor`         | string ou null         | À renvoyer en `cursor` pour la page suivante.                    |
| `has_more`            | boolean                |                                                                  |

### Exemple

```bash
curl -X GET "https://app.hgdc.ch/portal/api/v1/documents" \
  -H "Authorization: Bearer $HGDC_PORTAL_API_KEY"
```

Réponse `200` :

```json
{
  "data": [
    {
      "id": "exemple",
      "object": "exemple",
      "project_id": "exemple",
      "title": "exemple",
      "file_name": "exemple",
      "content_type": "exemple",
      "size": -9007199254740991,
      "sha256": "exemple",
      "visibility": "internal",
      "from_client": true,
      "created_at": "exemple"
    }
  ],
  "next_cursor": "exemple",
  "has_more": true
}
```
