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

# 组管理

> 创建组，管理参与者和管理员，处理加入请求，更改设置并发送到组。

所有群组路由都以设备为作用域：请发送 `X-Device-Id`。群组 ID 是以 `@g.us` 结尾的 JID，例如 `120363025246125486@g.us`。执行管理员操作要求该账号是群组管理员。

```bash theme={null}
export GOWA=http://localhost:3000 AUTH=admin:changeme DEVICE=my-device
```

## 创建和检查

```bash theme={null}
# create (participants: numbers or JIDs)
curl -u $AUTH -X POST $GOWA/group -H "X-Device-Id: $DEVICE" \
  -H "Content-Type: application/json" \
  -d '{"title": "Project Team", "participants": ["628111111111", "628222222222"]}'

# info and participants
curl -u $AUTH -H "X-Device-Id: $DEVICE" "$GOWA/group/info?group_id=120363025246125486@g.us"
curl -u $AUTH -H "X-Device-Id: $DEVICE" "$GOWA/group/participants?group_id=120363025246125486@g.us"

# participants as CSV
curl -u $AUTH -H "X-Device-Id: $DEVICE" "$GOWA/group/participants/export?group_id=120363025246125486@g.us" -o members.csv

# groups this account is in
curl -u $AUTH -H "X-Device-Id: $DEVICE" $GOWA/user/my/groups
```

## 参加者

同一机构致力于添加、移除、提升和降级：

```bash theme={null}
BODY='{"group_id": "120363025246125486@g.us", "participants": ["628333333333"]}'

curl -u $AUTH -X POST $GOWA/group/participants          -H "X-Device-Id: $DEVICE" -H "Content-Type: application/json" -d "$BODY"  # add
curl -u $AUTH -X POST $GOWA/group/participants/remove   -H "X-Device-Id: $DEVICE" -H "Content-Type: application/json" -d "$BODY"
curl -u $AUTH -X POST $GOWA/group/participants/promote  -H "X-Device-Id: $DEVICE" -H "Content-Type: application/json" -d "$BODY"
curl -u $AUTH -X POST $GOWA/group/participants/demote   -H "X-Device-Id: $DEVICE" -H "Content-Type: application/json" -d "$BODY"
```

WhatsApp 可能会因为其隐私设置而拒绝直接添加他人。将邀请链接发送给他们。

## 加入请求

对于需要管理员批准的组：

```bash theme={null}
curl -u $AUTH -H "X-Device-Id: $DEVICE" \
  "$GOWA/group/participant-requests?group_id=120363025246125486@g.us"

curl -u $AUTH -X POST $GOWA/group/participant-requests/approve \
  -H "X-Device-Id: $DEVICE" -H "Content-Type: application/json" \
  -d '{"group_id": "120363025246125486@g.us", "participants": ["628444444444"]}'
# reject: /group/participant-requests/reject with the same body
```

## 设置

| 设置 | Endpoint | 正文内容 |
| - | - | - |
| 名称 | `POST /group/name` | `{"group_id": "...", "name": "New name"}` |
| 描述 | `POST /group/topic` | `{"group_id": "...", "topic": "About this group"}`（设为空值可移除群组简介） |
| 照片 | `POST /group/photo` | 多部分: `group_id`, `photo` (略去`photo` ) |
| 仅管理员编辑信息 | `POST /group/locked` | `{"group_id": "...", "locked": true}` |
| 只有管理员发送 | `POST /group/announce` | `{"group_id": "...", "announce": true}` |

```bash theme={null}
curl -u $AUTH -X POST $GOWA/group/announce -H "X-Device-Id: $DEVICE" \
  -H "Content-Type: application/json" \
  -d '{"group_id": "120363025246125486@g.us", "announce": true}'
```

## 邀请链接

```bash theme={null}
# get the link (reset=true revokes the old one and creates a new one)
curl -u $AUTH -H "X-Device-Id: $DEVICE" \
  "$GOWA/group/invite-link?group_id=120363025246125486@g.us&reset=false"

# preview a group from a link without joining
curl -u $AUTH -H "X-Device-Id: $DEVICE" \
  "$GOWA/group/info-from-link?link=https://chat.whatsapp.com/AbCdEfGhIjKl"

# join
curl -u $AUTH -X POST $GOWA/group/join-with-link -H "X-Device-Id: $DEVICE" \
  -H "Content-Type: application/json" -d '{"link": "https://chat.whatsapp.com/AbCdEfGhIjKl"}'

# leave
curl -u $AUTH -X POST $GOWA/group/leave -H "X-Device-Id: $DEVICE" \
  -H "Content-Type: application/json" -d '{"group_id": "120363025246125486@g.us"}'
```

## 消息组

将群组 JID 作为 `phone` 参数传入任意 `/send/*` 端点。通过 `mentions` 提及成员，或通过 `"@everyone"` 提及所有人：

```bash theme={null}
curl -u $AUTH -X POST $GOWA/send/message -H "X-Device-Id: $DEVICE" \
  -H "Content-Type: application/json" \
  -d '{"phone": "120363025246125486@g.us", "message": "Standup in 5 minutes", "mentions": ["@everyone"]}'
```

## 组事件

订阅 `group.participants` (加入，请假，推广，降级) 和 `group.joined` (您被添加) webhooks. 有效载荷示例：

```json theme={null}
{
  "event": "group.participants",
  "device_id": "628123456789@s.whatsapp.net",
  "payload": {"chat_id": "120363025246125486@g.us", "type": "join", "jids": ["628333333333@s.whatsapp.net"]}
}
```


## Related topics

- [撤销消息](https://gowa-docs.mintlify.site/zh/api-reference/message/撤销消息.md)
- [提升参与者到管理员](https://gowa-docs.mintlify.site/zh/api-reference/group/提升参与者到管理员.md)
- [添加新设备](https://gowa-docs.mintlify.site/zh/api-reference/device/添加新设备.md)
- [多设备与设备选择](https://gowa-docs.mintlify.site/zh/concepts/multidevice.md)
- [设置群组公告模式](https://gowa-docs.mintlify.site/zh/api-reference/group/设置群组公告模式.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.