> ## 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.

# Rétrograder admin

> Rétrograder des administrateurs en membres normaux.

## Endpoints

### Option 1: GroupJid dans le body

```http theme={null}
POST https://api.wachap.com/v1/whatsapp/groups/members
```

### Option 2: GroupJid dans l'URL (rétrocompatibilité)

```http theme={null}
POST https://api.wachap.com/v1/whatsapp/groups/:groupJid/members
```

## Headers

| Paramètre     | Type   | Requis | Description                                                  |
| :------------ | :----- | :----- | :----------------------------------------------------------- |
| Authorization | string | Oui    | Bearer token avec votre Secret Key (format: `Bearer sk_...`) |

## Body Parameters (Option 1)

| Paramètre    | Type   | Requis | Description                                                 |
| :----------- | :----- | :----- | :---------------------------------------------------------- |
| accountId    | string | Oui    | L'identifiant du compte WhatsApp                            |
| groupJid     | string | Oui    | L'identifiant du groupe (format: `120363123456789012@g.us`) |
| action       | string | Oui    | Action à effectuer: `demote`                                |
| participants | array  | Oui    | Liste des numéros de téléphone au format international      |

## Body Parameters (Option 2)

| Paramètre    | Type   | Requis | Description                                            |
| :----------- | :----- | :----- | :----------------------------------------------------- |
| accountId    | string | Oui    | L'identifiant du compte WhatsApp                       |
| action       | string | Oui    | Action à effectuer: `demote`                           |
| participants | array  | Oui    | Liste des numéros de téléphone au format international |

## Exemple de requête

```bash theme={null}
curl -X POST https://api.wachap.com/v1/whatsapp/groups/members \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer token" \
  -d '{
    "accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
    "groupJid": "120363123456789012@g.us",
    "action": "demote",
    "participants": ["+33612345678"]
  }'
```

## Exemple de réponse

```json theme={null}
{
  "success": true,
  "message": "Participants rétrogradés avec succès",
  "action": "demote",
  "groupJid": "120363123456789012@g.us",
  "demotedCount": 1
}
```

## Notes

* Seul le créateur du groupe (superadmin) peut rétrograder des administrateurs
* Vous ne pouvez pas vous rétrograder vous-même

## Codes d'erreur

| Code | Description                                                           |
| :--- | :-------------------------------------------------------------------- |
| 400  | `MISSING_ACCOUNT_ID` - accountId manquant                             |
| 400  | `MISSING_GROUP_JID` - groupJid manquant                               |
| 400  | `MISSING_ACTION` - action manquante                                   |
| 400  | `MISSING_PARTICIPANTS` - participants manquant ou vide                |
| 401  | `INVALID_SECRET_KEY` - Clé secrète invalide                           |
| 403  | `NOT_CREATOR` - Seul le créateur peut rétrograder des administrateurs |
| 403  | `CANNOT_DEMOTE_SELF` - Impossible de se rétrograder soi-même          |
| 404  | `ACCOUNT_NOT_FOUND` - Compte WhatsApp non trouvé                      |
| 404  | `GROUP_NOT_FOUND` - Groupe non trouvé                                 |


## OpenAPI

````yaml POST /whatsapp/groups/members
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/groups/members:
    post:
      tags:
        - Groupes WhatsApp
      summary: Gérer les membres
      description: >-
        Ajoutez, retirez, promouvez ou rétrograder des membres dans un groupe
        WhatsApp.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                accountId:
                  type: string
                groupJid:
                  type: string
                action:
                  type: string
                  enum:
                    - add
                    - remove
                    - promote
                    - demote
                  description: Action à effectuer
                participants:
                  type: array
                  items:
                    type: string
                  description: Liste des numéros de téléphone (format international)
      responses:
        '200':
          description: OK
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````