> ## Documentation Index
> Fetch the complete documentation index at: https://dev.wachap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Appliquer une étiquette

> Associez une étiquette à une conversation WhatsApp

### Endpoint

<ParamField method="POST" path="/v1/whatsapp/labels/apply" />

### Body Parameters

<ParamField body="accountId" type="string" required>
  Identifiant du compte WhatsApp.
</ParamField>

<ParamField body="labelId" type="string">
  Identifiant d’une étiquette existante.
</ParamField>

<ParamField body="labelName" type="string">
  Nom d’une étiquette existante lorsque vous ne disposez pas de `labelId`.
</ParamField>

<ParamField body="createIfMissing" type="boolean">
  Crée l’étiquette `labelName` si elle n’existe pas. Ce champ est facultatif et vaut `false` par défaut.
</ParamField>

<ParamField body="color" type="integer">
  Couleur utilisée uniquement si l’étiquette doit être créée.
</ParamField>

<ParamField body="conversationJid" type="string">
  JID complet de la conversation. Fournissez `conversationJid` ou `phone`.
</ParamField>

<ParamField body="phone" type="string">
  Numéro au format international lorsque le JID n’est pas connu.
</ParamField>

### Exemple avec création automatique

```bash theme={null}
curl -X POST https://api.wachap.com/v1/whatsapp/labels/apply \
  -H "Authorization: Bearer token" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "account_123",
    "labelName": "Nouveau prospect",
    "createIfMissing": true,
    "color": 3,
    "phone": "+2290100000000"
  }'
```

### Réponse

```json theme={null}
{
  "success": true,
  "label": {
    "labelId": "label_prospect",
    "name": "Nouveau prospect",
    "color": 3,
    "deleted": false
  },
  "assignment": {
    "accountId": "account_123",
    "labelId": "label_prospect",
    "conversationJid": "2290100000000@s.whatsapp.net",
    "phone": "2290100000000",
    "labeled": true,
    "source": "api"
  }
}
```


## OpenAPI

````yaml POST /whatsapp/labels/apply
openapi: 3.0.3
info:
  title: WaChap API
  version: 2.0.0
servers:
  - url: https://api.wachap.com/v1
    description: WaChap API server
security:
  - BearerAuth: []
tags:
  - name: Instances
    description: Créer et gérer des instances WhatsApp
  - name: Webhook
    description: Configuration des webhooks de réception
  - name: Messages
    description: Envoyer des messages WhatsApp
  - name: Comptes
    description: Gérer vos comptes WhatsApp connectés
  - name: SMS
    description: Service SMS de WaChap (V4) via FCM
  - name: Étiquettes WhatsApp
    description: Créer et associer des étiquettes aux conversations WhatsApp
paths:
  /whatsapp/labels/apply:
    post:
      tags:
        - Étiquettes WhatsApp
      summary: Appliquer une étiquette à une conversation
      description: >-
        Utilisez labelId ou labelName. Activez createIfMissing pour créer une
        étiquette absente. Ciblez la conversation avec conversationJid ou phone.
      operationId: applyWhatsAppLabel
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - accountId
              properties:
                accountId:
                  type: string
                labelId:
                  type: string
                labelName:
                  type: string
                createIfMissing:
                  type: boolean
                  default: false
                color:
                  type: integer
                conversationJid:
                  type: string
                chatJid:
                  type: string
                phone:
                  type: string
                to:
                  type: string
            examples:
              existingLabel:
                value:
                  accountId: account_123
                  labelId: label_vip
                  phone: '+2290100000000'
              createByName:
                value:
                  accountId: account_123
                  labelName: Nouveau prospect
                  createIfMissing: true
                  color: 3
                  phone: '+2290100000000'
      responses:
        '200':
          description: Étiquette appliquée
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  label:
                    $ref: '#/components/schemas/WhatsAppLabel'
                  assignment:
                    $ref: '#/components/schemas/WhatsAppLabelAssignment'
        '404':
          description: LABEL_NOT_FOUND
        '409':
          description: APP_STATE_RESET_REQUIRED
components:
  schemas:
    WhatsAppLabel:
      type: object
      properties:
        id:
          type: string
        userId:
          type: string
        accountId:
          type: string
        labelId:
          type: string
        name:
          type: string
        color:
          type: integer
        deleted:
          type: boolean
        createdAt:
          type: string
        updatedAt:
          type: string
        syncedAt:
          type: string
        fromSync:
          type: boolean
        source:
          type: string
    WhatsAppLabelAssignment:
      type: object
      properties:
        accountId:
          type: string
        labelId:
          type: string
        conversationJid:
          type: string
        phone:
          type: string
        labeled:
          type: boolean
        updatedAt:
          type: string
        syncedAt:
          type: string
        fromSync:
          type: boolean
        source:
          type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````