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

# WhatsApp 群组生命周期更新 Webhook 示例

> 处理 WhatsApp 群组创建和删除结果。

<Note>如需查看基于 Schema 生成的完整目录，请参阅[所有示例](/zh/api-reference/guides/examples/webhook-examples/webhook-payload-examples)。</Note>

## 功能简介

处理 WhatsApp 群组创建和删除结果。

## 准备工作

* 在您的应用程序中创建一个公开的 HTTPS 端点。
* 为您所需的事件类型配置 YCloud Webhook 端点。
* 安全存储端点签名密钥。
* 确保事件处理具备幂等性。

## 工作原理

事件发生时，YCloud 会发送 HTTP `POST` 请求。请验证签名、持久化记录事件、返回 `2xx` 响应，并异步处理耗时操作。

## 请求

以下场景展示了发送至您的 Webhook URL 的请求。将事件 `id` 作为投递标识符，并使用 `type` 对载荷进行路由。

## 响应

接收事件后返回 `2xx` 状态。

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

<Note>有关端点设置、签名验证和重试机制的详细信息，请参阅[配置 Webhook](/zh/api-reference/guides/api-fundamentals/configure-webhooks)。</Note>

<br />

## 群组已创建

成功创建 WhatsApp 群组后，您将收到具有以下载荷结构的 Webhook：

### 请求

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_group_lifecycle_123",
  "type": "whatsapp.group.lifecycle_update",
  "apiVersion": "v2",
  "createTime": "2026-05-13T00:00:00.000Z",
  "whatsappGroup": {
    "wabaId": "123456789012345",
    "displayPhoneNumber": "16315551111",
    "phoneNumberId": "1234567890123456",
    "field": "group_lifecycle_update",
    "type": "group_create",
    "requestId": "REQ_1",
    "status": "created",
    "groupId": "Y2FwaV9ncm91cDpFWEFNUExFX0dST1VQX0lE",
    "inviteLink": "https://chat.whatsapp.com/AbCdEfGhIjK",
    "subject": "New Purchase Inquiry",
    "description": "Group for purchase inquiries.",
    "joinApprovalMode": "auto_approve",
    "webhookTime": "2026-05-13T00:00:00.000Z",
    "dedupeKey": "123456789012345|REQ_1|group_lifecycle_update|group_create|created"
  }
}
```

### 响应

在持久化接收事件后确认投递。

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

### 说明

根据 `type` 路由事件，使用 `id` 进行去重，并将耗时或易出错的操作移至异步处理器。

## 群组已删除

删除 WhatsApp 群组后，您将收到具有以下载荷结构的 Webhook：

### 请求

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_group_lifecycle_124",
  "type": "whatsapp.group.lifecycle_update",
  "apiVersion": "v2",
  "createTime": "2026-05-13T00:00:00.000Z",
  "whatsappGroup": {
    "wabaId": "123456789012345",
    "field": "group_lifecycle_update",
    "type": "group_delete",
    "requestId": "REQ_DELETE",
    "status": "deleted",
    "groupId": "Y2FwaV9ncm91cDpFWEFNUExFX0dST1VQX0lE",
    "webhookTime": "2026-05-13T00:00:00.000Z"
  }
}
```

### 响应

在持久化接收事件后确认投递。

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

### 说明

* **type**：群组生命周期事件始终为 `whatsapp.group.lifecycle_update`
* **whatsappGroup**：包含群组生命周期结果详情
  * **field**：始终为 `group_lifecycle_update`
  * **type**：生命周期操作，例如 `group_create` 或 `group_delete`
  * **requestId**：异步群组 API 操作返回的请求 ID
  * **status**：归一化后的结果状态，例如 `created`、`deleted` 或 `failed`
  * **groupId**：WhatsApp 群组 ID
  * **inviteLink**：群组邀请链接，在群组创建成功时包含
  * **dedupeKey**：用于对群组生命周期 Webhook 事件进行去重的幂等键

<br />


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