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

# contact.attributes_changed

> 当联系人的属性发生变更时触发。

在您的 Webhook 端点中使用 `contact.attributes_changed` 处理此事件。

## 触发条件

当联系人的属性发生变更时触发。

在您[配置 Webhook 端点](https://docs.ycloud.com/zh/api-reference/guides/api-fundamentals/configure-webhooks.md)时订阅 `contact.attributes_changed`。

## 语法

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

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "<ID>",
  "type": "contact.attributes_changed",
  "apiVersion": "<API_VERSION>",
  "createTime": "<CREATE_TIME>",
  "contactAttributesChanged": {
    "id": "<ID>",
    "updateTime": "<UPDATE_TIME>",
    "changedAttributes": {
      "remark_name": {
        "oldValue": "<OLD_VALUE>",
        "newValue": "<NEW_VALUE>"
      },
      "email": {
        "oldValue": "<OLD_VALUE>",
        "newValue": "<NEW_VALUE>"
      },
      "tags": {
        "oldValue": [
          "<OLD_VALUE>"
        ],
        "newValue": [
          "<NEW_VALUE>"
        ],
        "extra": [
          {
            "action": "<ACTION>",
            "id": "<ID>",
            "value": "<VALUE>"
          }
        ]
      }
    }
  }
}
```

## 参数

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

### 事件外层封装

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

### 事件载荷

| 参数 | 类型 | 必填 | 描述 |
| - | - | - | - |
| `contactAttributesChanged` | object | 否 | 事件专用的 `contactAttributesChanged` 载荷。 |

四个通用封装字段为必填项。载荷字段取决于事件变体。在每个对象表格中， **必填** 适用于其父对象存在的情况。可选字段可省略；示例中的字段并不代表其为必填项。

#### contactAttributesChanged

| 参数 | 类型 | 必填 | 描述 |
| - | - | - | - |
| `id` | string | 是 | 属性发生变更的联系人 ID。 |
| `updateTime` | string (date-time) | 是 | 联系人属性更新的时间，格式采用 [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339)。例如 `2022-06-01T12:00:00.000Z`。 |
| `changedAttributes` | object | 是 | 包含已变更属性的对象。每个键代表变更属性的名称，其值包含旧值、新值和变更操作。键使用联系人属性目录名称，包括系统键，如 `remark_name`、`country_code` 和 `meta_username`。 |

## 示例

以下 JSON 是发送至接收端的内容。ID、电话号码及其他账户值仅供参考。

> [accordion] 联系人属性变更事件
>
> 联系人属性发生变更时的示例载荷
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_1234567890",
>   "type": "contact.attributes_changed",
>   "apiVersion": "v2",
>   "createTime": "2024-01-01T12:00:00.000Z",
>   "contactAttributesChanged": {
>     "id": "1824266594102064128",
>     "updateTime": "2024-01-01T12:00:00.000Z",
>     "changedAttributes": {
>       "remark_name": {
>         "oldValue": "Standard customer",
>         "newValue": "Priority customer"
>       },
>       "email": {
>         "oldValue": "john.doe@example.com",
>         "newValue": "johnny.doe@example.com"
>       },
>       "tags": {
>         "oldValue": [
>           "premium",
>           "newsletter"
>         ],
>         "newValue": [
>           "premium",
>           "newsletter",
>           "vip"
>         ],
>         "extra": [
>           {
>             "action": "ADDED",
>             "id": "686dd294334be8606a5bf312",
>             "value": "vip"
>           }
>         ]
>       }
>     }
>   }
> }
> ```

> [accordion] 标签变更示例（添加标签）
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_1234567892",
>   "type": "contact.attributes_changed",
>   "apiVersion": "v2",
>   "createTime": "2024-01-01T12:00:00.000Z",
>   "contactAttributesChanged": {
>     "id": "1824266594102064128",
>     "updateTime": "2024-01-01T12:00:00.000Z",
>     "changedAttributes": {
>       "tags": {
>         "oldValue": [
>           "premium",
>           "newsletter"
>         ],
>         "newValue": [
>           "premium",
>           "newsletter",
>           "vip"
>         ],
>         "extra": [
>           {
>             "action": "ADDED",
>             "id": "686dd294334be8606a5bf312",
>             "value": "vip"
>           }
>         ]
>       }
>     }
>   }
> }
> ```

> [accordion] 标签变更示例（移除标签）
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_1234567893",
>   "type": "contact.attributes_changed",
>   "apiVersion": "v2",
>   "createTime": "2024-01-01T12:00:00.000Z",
>   "contactAttributesChanged": {
>     "id": "1824266594102064128",
>     "updateTime": "2024-01-01T12:00:00.000Z",
>     "changedAttributes": {
>       "tags": {
>         "oldValue": [
>           "premium",
>           "newsletter",
>           "vip"
>         ],
>         "newValue": [
>           "premium",
>           "newsletter"
>         ],
>         "extra": [
>           {
>             "action": "REMOVED",
>             "id": "686dd294334be8606a5bf312",
>             "value": "vip"
>           }
>         ]
>       }
>     }
>   }
> }
> ```

> [accordion] 变更示例
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_1234567900",
>   "type": "contact.attributes_changed",
>   "apiVersion": "v2",
>   "createTime": "2024-01-01T12:00:00.000Z",
>   "contactAttributesChanged": {
>     "id": "1824266594102064128",
>     "updateTime": "2024-01-01T12:00:00.000Z",
>     "changedAttributes": {
>       "waba_id": {
>         "oldValue": "waba_old_123456",
>         "newValue": "waba_new_789012",
>         "extra": [
>           {
>             "action": "CHANGED"
>           }
>         ]
>       }
>     }
>   }
> }
> ```

验证签名并持久接收事件后，返回 `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/contact-attributes-changed-webhook-examples)。


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