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

# Gruppen

> Erstellen, verwalten und interagieren Sie programmatisch mit WhatsApp-Gruppen.

# Gruppen

Verwalten Sie WhatsApp-Gruppen ueber die Wappfy API. Sie koennen Gruppen erstellen, Teilnehmer verwalten, Einladungslinks handhaben und vieles mehr.

Alle Gruppen-Endpunkte beziehen sich auf eine bestimmte Instanz:

```
/api/instances/{instanceId}/groups/...
```

***

## Gruppe erstellen

Erstellen Sie eine neue WhatsApp-Gruppe mit ersten Teilnehmern.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/groups \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Project Alpha",
      "participants": [
        "5511999998888@s.whatsapp.net",
        "5511888887777@s.whatsapp.net"
      ]
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/groups",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        name: "Project Alpha",
        participants: [
          "5511999998888@s.whatsapp.net",
          "5511888887777@s.whatsapp.net",
        ],
      }),
    }
  );

  const group = await response.json();
  console.log(group.data.group_id);
  ```
</CodeGroup>

**Antwort:**

```json theme={null}
{
  "data": {
    "group_id": "120363012345678901@g.us",
    "name": "Project Alpha",
    "participants": [
      {
        "id": "5511999998888@s.whatsapp.net",
        "is_admin": false
      },
      {
        "id": "5511888887777@s.whatsapp.net",
        "is_admin": false
      }
    ]
  }
}
```

***

## Gruppen auflisten

Rufen Sie alle Gruppen ab, in denen die Instanz Mitglied ist.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.wappfy.io/api/instances/inst_abc123/groups \
    -H "X-Api-Key: YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/groups",
    {
      headers: { "X-Api-Key": "YOUR_API_KEY" },
    }
  );

  const { data } = await response.json();
  console.log(`Found ${data.length} groups`);
  ```
</CodeGroup>

**Antwort:**

```json theme={null}
{
  "data": [
    {
      "group_id": "120363012345678901@g.us",
      "name": "Project Alpha",
      "participant_count": 5
    },
    {
      "group_id": "120363098765432109@g.us",
      "name": "Support Team",
      "participant_count": 12
    }
  ]
}
```

***

## Gruppeninformationen abrufen

Rufen Sie detaillierte Informationen zu einer bestimmten Gruppe ab.

```bash theme={null}
curl https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us \
  -H "X-Api-Key: YOUR_API_KEY"
```

**Antwort:**

```json theme={null}
{
  "data": {
    "group_id": "120363012345678901@g.us",
    "name": "Project Alpha",
    "description": "Team workspace for Project Alpha",
    "owner": "5511999998888@s.whatsapp.net",
    "created_at": "2026-01-15T10:00:00Z",
    "participants": [
      {
        "id": "5511999998888@s.whatsapp.net",
        "is_admin": true,
        "is_super_admin": true
      },
      {
        "id": "5511888887777@s.whatsapp.net",
        "is_admin": false,
        "is_super_admin": false
      }
    ]
  }
}
```

***

## Gruppe aktualisieren

Aktualisieren Sie den Gruppennamen oder die Beschreibung. Sie muessen Gruppenadmin sein, um diese Aktion durchzufuehren.

```bash theme={null}
curl -X PATCH https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Project Alpha v2",
    "description": "Updated workspace for Project Alpha"
  }'
```

<Note>
  Nur Gruppenadmins koennen den Gruppennamen und die Beschreibung aktualisieren. Wenn die Instanz kein Admin ist, wird ein `403`-Fehler zurueckgegeben.
</Note>

***

## Gruppe verlassen

Entfernen Sie die Instanz aus einer Gruppe.

```bash theme={null}
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us/leave \
  -H "X-Api-Key: YOUR_API_KEY"
```

<Warning>
  Nach dem Verlassen einer Gruppe benoetigen Sie einen Einladungslink oder einen anderen Admin, der Sie wieder hinzufuegt.
</Warning>

***

## Teilnehmer

### Teilnehmer auflisten

Rufen Sie alle Teilnehmer einer Gruppe ab.

```bash theme={null}
curl https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us/participants \
  -H "X-Api-Key: YOUR_API_KEY"
```

**Antwort:**

```json theme={null}
{
  "data": [
    {
      "id": "5511999998888@s.whatsapp.net",
      "is_admin": true,
      "is_super_admin": true
    },
    {
      "id": "5511888887777@s.whatsapp.net",
      "is_admin": false,
      "is_super_admin": false
    },
    {
      "id": "5511777776666@s.whatsapp.net",
      "is_admin": true,
      "is_super_admin": false
    }
  ]
}
```

### Teilnehmer hinzufuegen

Fuegen Sie einen oder mehrere Teilnehmer zu einer Gruppe hinzu. Sie muessen Gruppenadmin sein.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us/participants \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "participants": [
        "5511666665555@s.whatsapp.net",
        "5511555554444@s.whatsapp.net"
      ]
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    "https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us/participants",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        participants: [
          "5511666665555@s.whatsapp.net",
          "5511555554444@s.whatsapp.net",
        ],
      }),
    }
  );
  ```
</CodeGroup>

### Teilnehmer entfernen

Entfernen Sie einen oder mehrere Teilnehmer aus einer Gruppe. Sie muessen Gruppenadmin sein.

```bash theme={null}
curl -X DELETE https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us/participants \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "participants": [
      "5511666665555@s.whatsapp.net"
    ]
  }'
```

***

## Einladungscodes

### Einladungscode abrufen

Erstellen oder rufen Sie den Einladungslink der Gruppe ab. Sie muessen Gruppenadmin sein.

```bash theme={null}
curl https://api.wappfy.io/api/instances/inst_abc123/groups/120363012345678901@g.us/invite-code \
  -H "X-Api-Key: YOUR_API_KEY"
```

**Antwort:**

```json theme={null}
{
  "data": {
    "invite_code": "https://chat.whatsapp.com/AbCdEfGhIjKlMn"
  }
}
```

### Per Einladungscode beitreten

Treten Sie einer Gruppe ueber einen Einladungscode bei.

```bash theme={null}
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/groups/join \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "invite_code": "AbCdEfGhIjKlMn"
  }'
```

<Note>
  Uebergeben Sie nur den Code-Teil, nicht die vollstaendige URL. Fuer `https://chat.whatsapp.com/AbCdEfGhIjKlMn` uebergeben Sie `AbCdEfGhIjKlMn`.
</Note>

***

## Nachrichten an Gruppen senden

Um eine Nachricht an eine Gruppe zu senden, verwenden Sie den Standard-Endpunkt zum [Nachrichten senden](/de/guides/sending-messages) mit der Chat-ID der Gruppe:

```bash theme={null}
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "120363012345678901@g.us",
    "type": "text",
    "text": "Hello team!"
  }'
```

Gruppenchat-IDs enden immer mit `@g.us`.

***

## Endpunkt-Referenz

| Methode  | Endpunkt                                            | Beschreibung                           |
| -------- | --------------------------------------------------- | -------------------------------------- |
| `POST`   | `/api/instances/{id}/groups`                        | Neue Gruppe erstellen                  |
| `GET`    | `/api/instances/{id}/groups`                        | Alle Gruppen auflisten                 |
| `GET`    | `/api/instances/{id}/groups/{groupId}`              | Gruppeninformationen abrufen           |
| `PATCH`  | `/api/instances/{id}/groups/{groupId}`              | Gruppenname/Beschreibung aktualisieren |
| `POST`   | `/api/instances/{id}/groups/{groupId}/leave`        | Gruppe verlassen                       |
| `GET`    | `/api/instances/{id}/groups/{groupId}/participants` | Teilnehmer auflisten                   |
| `POST`   | `/api/instances/{id}/groups/{groupId}/participants` | Teilnehmer hinzufuegen                 |
| `DELETE` | `/api/instances/{id}/groups/{groupId}/participants` | Teilnehmer entfernen                   |
| `GET`    | `/api/instances/{id}/groups/{groupId}/invite-code`  | Einladungscode abrufen                 |
| `POST`   | `/api/instances/{id}/groups/join`                   | Per Einladungscode beitreten           |

***

## Fehlerbehandlung

| Statuscode | Beschreibung                                                                                       |
| ---------- | -------------------------------------------------------------------------------------------------- |
| `403`      | Sie sind kein Admin dieser Gruppe.                                                                 |
| `404`      | Gruppe nicht gefunden oder Instanz ist kein Mitglied.                                              |
| `409`      | Teilnehmer ist bereits in der Gruppe (beim Hinzufuegen) oder nicht in der Gruppe (beim Entfernen). |
| `422`      | Ungueltiges Teilnehmerformat. Verwenden Sie `{phone}@s.whatsapp.net`.                              |
