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

> 在 WhatsApp 消息模板类别发生更新时触发。

使用 `whatsapp.template.category_updated` 在您的 Webhook 端点处处理此事件。

## 触发条件

在 WhatsApp 消息模板类别发生更新时触发。

[配置您的 Webhook 端点](https://docs.ycloud.com/zh/api-reference/guides/api-fundamentals/configure-webhooks.md)时，订阅 `whatsapp.template.category_updated`。

比对 `previousCategory` 与 `category` 即可确定类别的变更情况。

## 语法

YCloud 会向您配置的 Webhook URL 发送一个 HTTP `POST` 请求。以下结构展示了一种载荷变体。尖括号内的值为占位符；其类型列在 **参数** 下方。可选字段及其他变体将在下文中说明。

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "<ID>",
  "type": "whatsapp.template.category_updated",
  "apiVersion": "<API_VERSION>",
  "createTime": "<CREATE_TIME>",
  "whatsappTemplate": {
    "officialTemplateId": "<OFFICIAL_TEMPLATE_ID>",
    "wabaId": "<WABA_ID>",
    "name": "<NAME>",
    "language": "<LANGUAGE>",
    "previousCategory": "<PREVIOUS_CATEGORY>",
    "category": "<CATEGORY>"
  }
}
```

## 参数

在处理 JSON 请求体之前，请先验证 `YCloud-Signature` HTTP 请求头。参见[签名验证](https://docs.ycloud.com/zh/api-reference/guides/api-fundamentals/configure-webhooks.md)。

### 事件外层封装

| 参数 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `id` | string | 是 | 事件的唯一 ID。最小长度：`6`。最大长度：`128`。 |
| `type` | string | 是 | 固定为 `whatsapp.template.category_updated`。 |
| `apiVersion` | string | 是 | 用于呈现此事件的 API 版本。 |
| `createTime` | string (date-time) | 是 | 此事件的创建时间，格式采用 [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339)。例如：`2022-06-01T12:00:00.000Z`。 |

### 事件载荷

| 参数 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `whatsappTemplate` | object | 否 | 特定事件的 `whatsappTemplate` 载荷。 |

外层封装的四个常用字段为必填项。载荷字段取决于具体事件变体。在各个对象表格中， **必填** 仅在其父对象存在时适用。可选字段可以省略；示例中出现并不代表该字段为必填。

#### whatsappTemplate

| 参数 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `officialTemplateId` | string | 否 | 由 WhatsApp 分配的官方模板 ID。该 ID 用于在 WhatsApp 系统中标识此模板。 |
| `wabaId` | string | 是 | WhatsApp 商业账户 ID。 |
| `name` | string | 是 | 模板名称。最大长度：`512`。正则模式：`[a-z0-9]{1,512}`。 |
| `language` | string | 是 | 模板的语言代码。所有代码参见[支持的语言](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/supported-languages)。 |
| `category` | string | 否 | WhatsApp 模板类别。<ul><li>`AUTHENTICATION`：支持商家使用一次性验证码对用户进行身份验证，可能涉及登录过程中的多个步骤（例如账户验证、账户恢复、完整性验证）。</li><li>`MARKETING`：包括促销或优惠、资讯更新，或邀请客户回复/采取行动。任何不属于效用或身份验证的对话均属于营销对话。</li><li>`UTILITY`：用于跟进特定的、双方约定的请求或交易，或向客户提供有关进行中交易的最新动态，包括购买后通知和周期性账单对账单。</li></ul> |
| `previousCategory` | string | 否 | 此字段表示模板先前的类别（对于 2023 年 4 月 1 日之后新创建的模板，为 `null`）。将此值与模板的 `category` 字段值进行比对，后者表示模板当前的类别。 |

## 示例

以下 JSON 是投递到您接收端的请求体。ID、电话号码和其他账户值仅供参考。

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_example_whatsapp_template_category_updated",
  "type": "whatsapp.template.category_updated",
  "apiVersion": "v2",
  "createTime": "2026-05-26T12:00:00.000Z",
  "whatsappTemplate": {
    "officialTemplateId": "official-template-id",
    "wabaId": "whatsapp-business-account-id",
    "name": "order_update",
    "language": "en_US",
    "previousCategory": "UTILITY",
    "category": "MARKETING"
  }
}
```

在验证签名并持久化接收事件后，返回 `2xx` 响应。耗时任务请异步处理。

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

有关具体场景演练，请参阅[带注释的示例](https://docs.ycloud.com/zh/api-reference/guides/examples/webhook-examples/whatsapp-template-reviewed-webhook-examples)。


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