# Templates

Soumettre des templates à la revue de Meta, suivre leur statut, les synchroniser.

## Soumettre un template à la revue de Meta

`POST /waba-connections/{wabaConnectionId}/templates`

Authentification : clé API, ou session de la console avec X-Environment-Id · portée : templates:manage

Paramètres :

| Nom | Emplacement | Type | Description |
|---|---|---|---|
| `wabaConnectionId` | path | string |  |

Corps (JSON) :

| Champ | Type | | Description |
|---|---|---|---|
| `name` | string | requis | Nom du template : minuscules, chiffres et underscores (ex. rappel_rdv). |
| `language` | string | requis | Code de langue : `fr`, `en`, `en_US`… |
| `category` | string | requis | Catégorie Meta : MARKETING, UTILITY ou AUTHENTICATION. Elle détermine la tarification chez Meta. |
| `components` | string[] | requis | Composants au format Meta |

```bash
curl -X POST "$INBOX_API/waba-connections/WABA_CONNECTION_ID/templates" \
  -H "Authorization: Bearer $INBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "rappel_rdv",
    "language": "fr",
    "category": "UTILITY",
    "components": [
      {
        "type": "BODY",
        "text": "Bonjour {{1}}, votre rendez-vous est confirmé pour le {{2}}.",
        "example": {
          "body_text": [
            [
              "Awa",
              "14 novembre à 10 h"
            ]
          ]
        }
      }
    ]
  }'
```

Réponse 201 :

```json
{
  "id": "ff532b8f-2956-4f04-851f-db09d5eefbd4",
  "name": "rappel_rdv",
  "language": "fr",
  "category": "UTILITY",
  "status": "pending",
  "usable": false,
  "rejectionReason": null,
  "components": [
    {
      "type": "BODY",
      "text": "Bonjour {{1}}, votre rendez-vous est confirmé pour le {{2}}.",
      "example": {
        "body_text": [
          [
            "Awa",
            "14 novembre à 10 h"
          ]
        ]
      }
    }
  ],
  "updatedAt": "2026-11-12T08:33:45.595Z"
}
```

## Templates du compte WhatsApp et leur statut de revue

`GET /waba-connections/{wabaConnectionId}/templates`

Authentification : clé API, ou session de la console avec X-Environment-Id · portée : templates:manage

Paramètres :

| Nom | Emplacement | Type | Description |
|---|---|---|---|
| `wabaConnectionId` | path | string |  |

```bash
curl "$INBOX_API/waba-connections/WABA_CONNECTION_ID/templates" \
  -H "Authorization: Bearer $INBOX_KEY"
```

Réponse 200 :

```json
[
  {
    "id": "ff532b8f-2956-4f04-851f-db09d5eefbd4",
    "name": "rappel_rdv",
    "language": "fr",
    "category": "UTILITY",
    "status": "approved",
    "usable": true,
    "rejectionReason": null,
    "components": [
      {
        "text": "Bonjour {{1}}, votre rendez-vous est confirmé pour le {{2}}.",
        "type": "BODY"
      }
    ],
    "updatedAt": "2026-11-12T08:33:45.640Z"
  }
]
```

## Synchroniser les statuts depuis Meta

`POST /waba-connections/{wabaConnectionId}/templates/sync`

Authentification : clé API, ou session de la console avec X-Environment-Id · portée : templates:manage

Paramètres :

| Nom | Emplacement | Type | Description |
|---|---|---|---|
| `wabaConnectionId` | path | string |  |

```bash
curl -X POST "$INBOX_API/waba-connections/WABA_CONNECTION_ID/templates/sync" \
  -H "Authorization: Bearer $INBOX_KEY"
```

Réponse 200 :

```json
[
  {
    "id": "ff532b8f-2956-4f04-851f-db09d5eefbd4",
    "name": "rappel_rdv",
    "language": "fr",
    "category": "UTILITY",
    "status": "approved",
    "usable": true,
    "rejectionReason": null,
    "components": [
      {
        "text": "Bonjour {{1}}, votre rendez-vous est confirmé pour le {{2}}.",
        "type": "BODY"
      }
    ],
    "updatedAt": "2026-11-12T08:33:45.640Z"
  }
]
```

## Supprimer un template (toutes ses langues)

`DELETE /waba-connections/{wabaConnectionId}/templates/{name}`

Authentification : clé API, ou session de la console avec X-Environment-Id · portée : templates:manage

Paramètres :

| Nom | Emplacement | Type | Description |
|---|---|---|---|
| `wabaConnectionId` | path | string |  |
| `name` | path | string |  |

```bash
curl -X DELETE "$INBOX_API/waba-connections/WABA_CONNECTION_ID/templates/NAME" \
  -H "Authorization: Bearer $INBOX_KEY"
```

Réponse 204 :

```json
(aucun contenu)
```
