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

# 联系人创建 Webhook 示例

> 处理联系人创建事件。

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

## 功能概述

处理联系人创建事件。

## 准备工作

* 在您的应用程序中创建一个公开的 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>

当新联系人被创建时触发。Webhook 有效载荷包含所创建联系人的完整信息。

## 联系人创建示例

### 请求

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_2345678901",
  "type": "contact.created",
  "apiVersion": "v2",
  "createTime": "2024-01-01T12:00:00.000Z",
  "contactCreated": {
    "id": "1824266594102064128",
    "nickName": "John Doe",
    "realName": "John Smith",
    "phoneNumber": "+16315551111",
    "countryCode": "US",
    "countryName": "United States",
    "email": "john.doe@example.com",
    "sourceType": "api",
    "sourceId": "import_batch_123",
    "sourceUrl": "https://example.com/signup",
    "lastSeen": "2024-01-01T11:59:00.000Z",
    "lastConnectedNumber": "+16315552222",
    "ownerEmail": "owner@example.com",
    "tags": [
      "premium",
      "newsletter"
    ],
    "createTime": "2024-01-01T12:00:00.000Z",
    "updateTime": "2024-01-01T12:00:00.000Z",
    "blocked": false,
    "customAttributes": {
      "company": "YCloud Inc",
      "age": 25
    }
  }
}
```

### 响应

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

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

<br />

### 说明

* **完整联系人信息**：`contactCreated` 对象包含创建时该联系人的所有可用信息。
* **自定义属性**：`customAttributes` 字段包含与该联系人关联的任何自定义数据。
* **标签**：`tags` 数组包含在创建期间分配给该联系人的所有标签。


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