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

# Groups

> WhatsApp groups को programmatically बनाएं, manage करें, और उनसे interact करें।

# Groups

Wappfy API के माध्यम से WhatsApp groups manage करें। आप groups बना सकते हैं, participants manage कर सकते हैं, invite links handle कर सकते हैं, और बहुत कुछ कर सकते हैं।

सभी group endpoints एक specific instance से जुड़े हैं:

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

***

## एक Group बनाएं

प्रारंभिक participants के साथ एक नया WhatsApp group बनाएं।

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

**Response:**

```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
      }
    ]
  }
}
```

***

## Groups की सूची

Instance जिन सभी groups का member है उन्हें प्राप्त करें।

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

**Response:**

```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
    }
  ]
}
```

***

## Group की जानकारी प्राप्त करें

किसी specific group की विस्तृत जानकारी fetch करें।

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

**Response:**

```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
      }
    ]
  }
}
```

***

## एक Group Update करें

Group का name या description update करें। यह action करने के लिए आपका group admin होना आवश्यक है।

```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>
  केवल group admins ही group name और description update कर सकते हैं। यदि instance admin नहीं है, तो यह `403` error लौटाएगा।
</Note>

***

## एक Group छोड़ें

Instance को group से हटाएं।

```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>
  Group छोड़ने के बाद, आपको वापस जोड़ने के लिए invite link या किसी अन्य admin की आवश्यकता होगी।
</Warning>

***

## Participants

### Participants की सूची

किसी group के सभी participants प्राप्त करें।

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

**Response:**

```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
    }
  ]
}
```

### Participants जोड़ें

Group में एक या अधिक participants जोड़ें। आपका group admin होना आवश्यक है।

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

### Participants हटाएं

Group से एक या अधिक participants हटाएं। आपका group admin होना आवश्यक है।

```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"
    ]
  }'
```

***

## Invite Codes

### Invite Code प्राप्त करें

Group का invite link generate या प्राप्त करें। आपका group admin होना आवश्यक है।

```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"
```

**Response:**

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

### Invite Code से Join करें

Invite code का उपयोग करके group में शामिल हों।

```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>
  केवल code भाग pass करें, पूर्ण URL नहीं। `https://chat.whatsapp.com/AbCdEfGhIjKlMn` के लिए, `AbCdEfGhIjKlMn` pass करें।
</Note>

***

## Groups में Messages भेजना

किसी group में message भेजने के लिए, group की chat ID के साथ standard [message भेजें](/hi/guides/sending-messages) endpoint का उपयोग करें:

```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!"
  }'
```

Group chat IDs हमेशा `@g.us` से समाप्त होती हैं।

***

## Endpoint Reference

| Method   | Endpoint                                            | विवरण                              |
| -------- | --------------------------------------------------- | ---------------------------------- |
| `POST`   | `/api/instances/{id}/groups`                        | नया group बनाएं                    |
| `GET`    | `/api/instances/{id}/groups`                        | सभी groups की सूची                 |
| `GET`    | `/api/instances/{id}/groups/{groupId}`              | Group की जानकारी प्राप्त करें      |
| `PATCH`  | `/api/instances/{id}/groups/{groupId}`              | Group name/description update करें |
| `POST`   | `/api/instances/{id}/groups/{groupId}/leave`        | Group छोड़ें                       |
| `GET`    | `/api/instances/{id}/groups/{groupId}/participants` | Participants की सूची               |
| `POST`   | `/api/instances/{id}/groups/{groupId}/participants` | Participants जोड़ें                |
| `DELETE` | `/api/instances/{id}/groups/{groupId}/participants` | Participants हटाएं                 |
| `GET`    | `/api/instances/{id}/groups/{groupId}/invite-code`  | Invite code प्राप्त करें           |
| `POST`   | `/api/instances/{id}/groups/join`                   | Invite code से join करें           |

***

## Error Handling

| Status Code | विवरण                                                                       |
| ----------- | --------------------------------------------------------------------------- |
| `403`       | आप इस group के admin नहीं हैं।                                              |
| `404`       | Group नहीं मिला या instance member नहीं है।                                 |
| `409`       | Participant पहले से group में है (add पर) या group में नहीं है (remove पर)। |
| `422`       | अमान्य participant format। `{phone}@s.whatsapp.net` का उपयोग करें।          |
