# Clients

## GET `/clients`

**Lister les clients de l’espace**

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

### Paramètres de requête

| Champ      | Type              | Obligatoire | Description                          |
| ---------- | ----------------- | ----------- | ------------------------------------ |
| `archived` | “true” \| “false” | Non         |                                      |
| `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[].name`         | string         |                                               |
| `data[].email`        | string ou null |                                               |
| `data[].contact_name` | string ou null |                                               |
| `data[].website`      | string ou null |                                               |
| `data[].ide`          | string ou null | Numéro IDE (CHE-…).                           |
| `data[].address`      | objet ou null  |                                               |
| `data[].archived`     | 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/clients" \
  -H "Authorization: Bearer $HGDC_PORTAL_API_KEY"
```

Réponse `200` :

```json
{
  "data": [
    {
      "id": "exemple",
      "object": "exemple",
      "name": "exemple",
      "email": "exemple",
      "contact_name": "exemple",
      "website": "exemple",
      "ide": "exemple",
      "address": {
        "name": "exemple",
        "street": "exemple",
        "building_number": "exemple",
        "extra": "exemple",
        "zip": "exemple",
        "city": "exemple",
        "country": "exemple"
      },
      "archived": true,
      "created_at": "exemple"
    }
  ],
  "next_cursor": "exemple",
  "has_more": true
}
```

## GET `/clients/{id}`

**Lire un client**

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

### Paramètres de chemin

| Champ | Type   | Obligatoire | Description |
| ----- | ------ | ----------- | ----------- |
| `id`  | string | Oui         |             |

### Réponses

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

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

| Champ          | Type           | Description                   |
| -------------- | -------------- | ----------------------------- |
| `id`           | string         | Identifiant Portal.           |
| `object`       | string         |                               |
| `name`         | string         |                               |
| `email`        | string ou null |                               |
| `contact_name` | string ou null |                               |
| `website`      | string ou null |                               |
| `ide`          | string ou null | Numéro IDE (CHE-…).           |
| `address`      | objet ou null  |                               |
| `archived`     | boolean        |                               |
| `created_at`   | string         | Date et heure ISO 8601 (UTC). |

### Exemple

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

Réponse `200` :

```json
{
  "id": "exemple",
  "object": "exemple",
  "name": "exemple",
  "email": "exemple",
  "contact_name": "exemple",
  "website": "exemple",
  "ide": "exemple",
  "address": {
    "name": "exemple",
    "street": "exemple",
    "building_number": "exemple",
    "extra": "exemple",
    "zip": "exemple",
    "city": "exemple",
    "country": "exemple"
  },
  "archived": true,
  "created_at": "exemple"
}
```
