**Versions de l’API** · [V2 (Latest)](/integrations/v2/docs?lang=fr) · **V1**

> **Cette version de l’API est obsolète.** Utilisez la dernière version pour toute nouvelle intégration. [Voir la documentation actuelle](/integrations/v2/docs?lang=fr)

# Campagnes de messages

OpenAPI 3.0.3 · API 1.0.0

```json
[
  {
    "url": "https://api.unisoft.world/integrations/v1",
    "description": "API"
  }
]
```

Campagnes de messages (WhatsApp / SMS / Email et cascades de remplacement). Le brouillon (état INIT) est entièrement modifiable ; l’ENVOI est une action DISTINCTE, à risque plus élevé, protégée par `messages:send` (envoi massif réel : coût SMS, risque de blocage WhatsApp, RGPD). Prévisualisez l’audience avec GET /{id}/targets avant l’envoi. Autorisations : `messages:read` (inclut aussi numéros WhatsApp et configurations de messagerie), `messages:write` (inclut aussi téléversements), `messages:send`.

## Opérations

## GET /campaigns

Lister les campagnes

`list_campaigns`

Autorisation requise : `messages:read`. Liste les campagnes de l’organisation avec leurs statistiques de livraison. Résultats paginés. Filtrez avec `?state` (INIT|VALIDATE|FINISHED) ou `?type`.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:read",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "limit",
  "in": "query",
  "schema": {
    "type": "integer",
    "minimum": 1,
    "maximum": 200,
    "default": 50
  },
  "description": "Nombre de résultats par page."
}
```

```json
{
  "name": "cursor",
  "in": "query",
  "schema": {
    "type": "string"
  },
  "description": "Curseur opaque renvoyé par la requête précédente."
}
```

```json
{
  "name": "state",
  "in": "query",
  "schema": {
    "type": "string",
    "enum": [
      "INIT",
      "VALIDATE",
      "FINISHED"
    ]
  }
}
```

```json
{
  "name": "type",
  "in": "query",
  "schema": {
    "type": "string"
  }
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Campaign"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      }
    }
  }
}
```

#### HTTP 401

```json
{
  "description": "ERREUR",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 403

```json
{
  "description": "AUTORISATION_INSUFFISANTE",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "INSUFFICIENT_SCOPE"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:read",
  "x-unisoft-mcp": {
    "category": "read",
    "readOnly": true,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## POST /campaigns

Créer une campagne (brouillon)

`create_campaign`

Autorisation requise : `messages:write`. Crée une campagne à l’état INIT (brouillon). N’effectue PAS l’envoi — utilisez POST /{id}/send. Le ciblage est exclusif (allContact | staredOnly | categories).

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:write",
  "additional": []
}
```

### Corps de la requête

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/CampaignInput"
      }
    }
  }
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/Campaign"
          }
        }
      }
    }
  }
}
```

#### HTTP 400

```json
{
  "description": "ERREUR_DE_VALIDATION",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "VALIDATION_ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 403

```json
{
  "description": "AUTORISATION_INSUFFISANTE",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "INSUFFICIENT_SCOPE"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:write",
  "x-unisoft-mcp": {
    "category": "create",
    "readOnly": false,
    "destructive": false,
    "idempotent": false,
    "warn": false
  }
}
```

## GET /campaigns/sms/available

Consulter le quota SMS restant

`get_sms_quota`

Autorisation requise : `messages:read`. Renvoie le nombre de crédits SMS restants de l’organisation (utile avant l’envoi d’une campagne SMS).

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:read",
  "additional": []
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "total": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:read",
  "x-unisoft-mcp": {
    "category": "read",
    "readOnly": true,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## GET /campaigns/{id}

Obtenir une campagne

`get_campaign`

Autorisation requise : `messages:read`. Campagne complète, avec ses statistiques de livraison.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:read",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/Campaign"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:read",
  "x-unisoft-mcp": {
    "category": "read",
    "readOnly": true,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## PATCH /campaigns/{id}

Modifier une campagne en brouillon

`update_campaign`

Autorisation requise : `messages:write`. Modifie une campagne uniquement tant qu’elle est à l’état INIT (brouillon). Renvoie 409 si elle a déjà été envoyée.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:write",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Corps de la requête

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/CampaignInput"
      }
    }
  }
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/Campaign"
          }
        }
      }
    }
  }
}
```

#### HTTP 400

```json
{
  "description": "ERREUR_DE_VALIDATION",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "VALIDATION_ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

#### HTTP 409

```json
{
  "description": "CAMPAIGN_NOT_EDITABLE",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "CAMPAIGN_NOT_EDITABLE"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:write",
  "x-unisoft-mcp": {
    "category": "update",
    "readOnly": false,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## DELETE /campaigns/{id}

Supprimer une campagne

`delete_campaign`

Autorisation requise : `messages:write`. Supprime logiquement la campagne.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:write",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:write",
  "x-unisoft-mcp": {
    "category": "delete",
    "readOnly": false,
    "destructive": true,
    "idempotent": true,
    "warn": false
  }
}
```

## POST /campaigns/{id}/duplicate

Dupliquer une campagne

`duplicate_campaign`

Autorisation requise : `messages:write`. Duplique la campagne sous forme de nouveau brouillon INIT (nouvel identifiant, scheduledAt effacé, statistiques réinitialisées ; médias partagés par référence).

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:write",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/Campaign"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:write",
  "x-unisoft-mcp": {
    "category": "create",
    "readOnly": false,
    "destructive": false,
    "idempotent": false,
    "warn": false
  }
}
```

## GET /campaigns/{id}/targets

Prévisualiser le nombre de destinataires

`preview_campaign_targets`

Autorisation requise : `messages:read`. Compte les destinataires correspondant au ciblage enregistré de la campagne, SANS créer de livraison. Renvoie 0 si aucun ciblage n’est défini.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:read",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CampaignTargets"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:read",
  "x-unisoft-mcp": {
    "category": "read",
    "readOnly": true,
    "destructive": false,
    "idempotent": true,
    "warn": false
  }
}
```

## POST /campaigns/{id}/send

Envoyer la campagne (envoi massif réel)

`send_campaign`

Autorisation requise : `messages:send`. **Déclenche l’envoi massif réel.** Fait passer le brouillon de INIT à VALIDATE et met en file une livraison par destinataire correspondant ; les processus envoient ensuite via WhatsApp/SMS/email. Action **irréversible**, susceptible d’entraîner des frais SMS, un risque de blocage du numéro WhatsApp (limites de débit) et des implications RGPD (messages envoyés à de vrais contacts). Prévisualisez d’abord l’audience avec POST /{id}/targets. Idempotent : une campagne déjà envoyée (state ≠ INIT) renvoie 409.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:send",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "data": {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string"
                  },
                  "targets": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

#### HTTP 409

```json
{
  "description": "CAMPAIGN_ALREADY_SENT",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "CAMPAIGN_ALREADY_SENT"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:send",
  "x-unisoft-mcp": {
    "category": "action",
    "readOnly": false,
    "destructive": true,
    "idempotent": false,
    "warn": true
  }
}
```

## POST /campaigns/{id}/test

Envoyer un test à un contact (brouillon uniquement)

`test_campaign`

Autorisation requise : `messages:send`. Envoie un seul message de test de la campagne à un contact (envoi réel à cette personne ; exclu des statistiques ; ignore la liste de désinscription). Autorisé UNIQUEMENT tant que la campagne est en brouillon (state INIT) — sinon renvoie 409. Corps : {contactId}.

### Authentification

```json
[
  {
    "bearerAuth": []
  },
  {
    "apiKeyHeader": []
  }
]
```

### Permissions requises

```json
{
  "accepted": "messages:send",
  "additional": []
}
```

### Paramètres

```json
{
  "name": "id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "string",
    "format": "uuid",
    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  },
  "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
}
```

### Corps de la requête

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/CampaignTestInput"
      }
    }
  }
}
```

### Réponses

#### HTTP 200

```json
{
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
```

#### HTTP 400

```json
{
  "description": "ERREUR_DE_VALIDATION",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "VALIDATION_ERROR"
          }
        }
      }
    }
  }
}
```

#### HTTP 404

```json
{
  "description": "NOT_FOUND",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "NOT_FOUND"
          }
        }
      }
    }
  }
}
```

#### HTTP 409

```json
{
  "description": "CAMPAIGN_NOT_DRAFT",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "CAMPAIGN_NOT_DRAFT"
          }
        }
      }
    }
  }
}
```

### OpenAPI

```json
{
  "x-unisoft-scope": "messages:send",
  "x-unisoft-mcp": {
    "category": "action",
    "readOnly": false,
    "destructive": true,
    "idempotent": false,
    "warn": true
  }
}
```

## Schémas

```json
{
  "components": {
    "parameters": {
      "LimitParam": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        },
        "description": "Nombre de résultats par page."
      },
      "CursorParam": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "Curseur opaque renvoyé par la requête précédente."
      },
      "IdParam": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid",
          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
        },
        "description": "Identifiant de ressource — doit être un UUID. Un identifiant mal formé est refusé avec 400 INVALID_UUID (pas simplement 404). Besoin d’un nouvel identifiant ? Appelez GET /utils/uuid."
      }
    },
    "schemas": {
      "Campaign": {
        "type": "object",
        "description": "Campagne de messages (collection messages) : envoi groupé WhatsApp/SMS/Email. Cycle de vie INIT (brouillon) → VALIDATE (envoyée) → FINISHED (terminée). `targets`/`percentSuccess`/`percentError` sont calculés à partir des livraisons.",
        "properties": {
          "crmTarget": {
            "type": "object",
            "readOnly": true,
            "description": "Ciblage versionné des listes/catégories de contacts. Union par défaut ; les exclusions sont prioritaires sur les inclusions. Relecture du back-office requise avant toute modification, prévisualisation ou envoi."
          },
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "WHATSAPP",
              "SMS",
              "EMAIL",
              "WHATSAPP_OU_SMS",
              "WHATSAPP_OU_EMAIL",
              "WHATSAPP_OU_SMS_OU_EMAIL",
              "SMS_OU_EMAIL"
            ],
            "description": "Canal ou cascade de remplacement."
          },
          "state": {
            "type": "string",
            "enum": [
              "INIT",
              "VALIDATE",
              "FINISHED"
            ],
            "readOnly": true,
            "description": "INIT = brouillon (modifiable) ; VALIDATE = envoi en cours/envoyée ; FINISHED = terminée."
          },
          "subject": {
            "type": "string",
            "description": "Objet de l’email (canaux EMAIL)."
          },
          "message": {
            "type": "string",
            "description": "Corps du message (texte, avec interpolation {{firstname}}/{{lastname}}/{{hebrewname}} ; les alias historiques {{prenom}}/{{nom}}/{{prenomHE}} restent pris en charge)."
          },
          "emailContent": {
            "type": "string",
            "description": "Corps complet de l’email HTML (alternative à emailTemplate)."
          },
          "emailTemplate": {
            "type": "string",
            "nullable": true,
            "description": "Identifiant d’un modèle d’email (son HTML est chargé dans emailContent au moment de l’envoi)."
          },
          "emailConfig": {
            "type": "string",
            "nullable": true,
            "description": "Identifiant de la configuration d’envoi d’email à utiliser (voir GET /messaging-configs)."
          },
          "smsConfig": {
            "type": "string",
            "nullable": true,
            "description": "Identifiant d’une configuration SMS — accepté pour compatibilité, mais IGNORÉ par le processus SMS (configuration unique par organisation)."
          },
          "whatsappAccountId": {
            "type": "string",
            "nullable": true,
            "description": "Identifiant du numéro WhatsApp émetteur (obligatoire lorsque type contient WHATSAPP)."
          },
          "allContact": {
            "type": "boolean",
            "description": "Ciblage : tous les contacts."
          },
          "staredOnly": {
            "type": "boolean",
            "description": "Ciblage : contacts locaux/épinglés (module Proximité)."
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ciblage : contacts appartenant à l’une de ces catégories."
          },
          "familles": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Champ historique, enregistré mais NON utilisé pour le ciblage."
          },
          "docs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignMedia"
            }
          },
          "videos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignMedia"
            }
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignLink"
            }
          },
          "prefix": {
            "type": "string"
          },
          "scheduledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Heure d’envoi (null = immédiatement après l’envoi de la commande)."
          },
          "datetime": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "targets": {
            "type": "integer",
            "readOnly": true,
            "description": "Nombre de livraisons (après l’envoi)."
          },
          "percentSuccess": {
            "type": "string",
            "readOnly": true
          },
          "percentError": {
            "type": "string",
            "readOnly": true
          }
        }
      },
      "CampaignMedia": {
        "type": "object",
        "description": "Élément de média de campagne. `doc` est une URL http(s) (réhébergée à l’écriture) ou un nom de fichier déjà hébergé (par ex. renvoyé par POST /uploads).",
        "properties": {
          "name": {
            "type": "string",
            "description": "Libellé d’affichage."
          },
          "doc": {
            "type": "string",
            "description": "URL http(s) (réhébergée) ou nom de fichier hébergé."
          }
        }
      },
      "CampaignLink": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "nextCursor": {
            "type": "string",
            "nullable": true
          },
          "hasMore": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "CampaignInput": {
        "type": "object",
        "description": "Les campagnes ciblant des listes de contacts exposent crmTarget en lecture ; leur modification, l’aperçu des destinataires et l’envoi nécessitent une revue du back-office (CONTACT_LIST_REVIEW_REQUIRED). Cette API refuse toute nouvelle valeur crmTarget. Créez ou modifiez une campagne de messages. Le ciblage est EXCLUSIF : définissez exactement l’un de `allContact`, `staredOnly` ou `categories`.\nLorsque `type` contient WHATSAPP, `whatsappAccountId` est OBLIGATOIRE et doit correspondre à un numéro connecté (voir GET /whatsapp-accounts).\nMédias (`docs`/`videos`) : le champ `doc` de chaque élément peut être une URL http(s) (réhébergée) ou un nom de fichier renvoyé par POST /uploads.\nUne campagne est créée dans l’état INIT (brouillon) ; elle ne peut être modifiée que dans cet état. L’envoi est une action distincte (POST /{id}/send, scope messages:send).",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "WHATSAPP",
              "SMS",
              "EMAIL",
              "WHATSAPP_OU_SMS",
              "WHATSAPP_OU_EMAIL",
              "WHATSAPP_OU_SMS_OU_EMAIL",
              "SMS_OU_EMAIL"
            ],
            "description": "Obligatoire à la création."
          },
          "whatsappAccountId": {
            "type": "string",
            "description": "Obligatoire lorsque type contient WHATSAPP."
          },
          "subject": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "emailContent": {
            "type": "string"
          },
          "emailTemplate": {
            "type": "string",
            "description": "Identifiant d’un modèle d’email existant."
          },
          "emailConfig": {
            "type": "string",
            "description": "Identifiant d’une configuration email existante (GET /messaging-configs)."
          },
          "smsConfig": {
            "type": "string",
            "description": "Identifiant d’une configuration SMS (accepté mais ignoré par le processus)."
          },
          "allContact": {
            "type": "boolean"
          },
          "staredOnly": {
            "type": "boolean"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "familles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "docs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignMedia"
            }
          },
          "videos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignMedia"
            }
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignLink"
            }
          },
          "prefix": {
            "type": "string"
          },
          "scheduledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "CampaignTargets": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "description": "Nombre de destinataires correspondant au ciblage."
          }
        }
      },
      "CampaignTestInput": {
        "type": "object",
        "required": [
          "contactId"
        ],
        "properties": {
          "contactId": {
            "type": "string",
            "description": "Contact auquel envoyer le message de test."
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Format : `ke_live_xxx`"
      },
      "apiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  }
}
```
