> For the complete documentation index, see [llms.txt](https://help.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/advocate-program-settings/create-and-manage-advocate-webhook-subscriptions.md).

# 创建并管理 Advocate Webhook 订阅

Webhook 是在事件发生时执行的代码。Advocate 允许你使用 webhook 注册一个 URL，每当你的程序中发生事件时，我们都会向该 URL 发送 POST 请求。例如，为新参与者创建专属优惠券代码时，会创建一个事件对象。创建和管理 webhook 有两种方式： [通过 Advocate API](https://integrations.impact.com/integration-guides/for-brands/advocate/advocate-api/api-webhooks-for-advocate-programs) 或在 Advocate 平台中。本文将介绍如何通过 Advocate 平台管理 webhook。

#### 创建 webhook 订阅

1. 在顶部导航栏中，选择 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2F210dEQa93qyQgoJDkieL%2FUser%20profile.svg?alt=media\&token=f84c5b17-fae4-4a30-990a-9de5e57a150b) **\[用户个人资料] → 设置**.
2. 在左侧栏的 *Advocate 设置*下，选择 **Webhook**.
3. 在 *Webhook 订阅* 页面中，选择 **创建订阅**.
4. 在 *发送到 URL*下方，输入应用用于发送特定事件实时更新的唯一地址。
5. 可选：在 *Webhook 名称*下方输入新 webhook 订阅的名称。
6. 选择 **保存**.

#### 排查 webhook 日志

注册一个 URL 后，Advocate 会在你的程序中发生事件时向该 URL 发送请求。你可以查看日志并排查失败的 webhook 事件。

**访问 webhook 日志**

1. 在顶部导航栏中，选择 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2F210dEQa93qyQgoJDkieL%2FUser%20profile.svg?alt=media\&token=f84c5b17-fae4-4a30-990a-9de5e57a150b) **\[用户个人资料] → 设置**.
2. 在左侧栏的 *Advocate 设置*下，选择 **Webhook**.
3. 在 *Webhook 订阅* 页面中，选择 **查看日志**.
4. 使用下方的筛选条件 *Webhook 事件日志* 来筛选 webhook。
   * 如需了解详情，请参阅下方的 *筛选条件参考* 。

<details>

<summary>筛选器参考</summary>

| 筛选条件 | 说明                                                                                                                                                            |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 类型   | 按 webhook [事件类型](https://integrations.impact.com/integration-guides/for-brands/advocate/advocate-api/api-webhooks-for-advocate-programs)筛选。此筛选条件默认设置为 *所有类型*. |
| 时间范围 | 按 webhook 最近一次更新的时间范围筛选。此筛选条件默认设置为 *所有时间*.                                                                                                                    |

</details>

**查看 webhook 详情**

1. 选择特定的 webhook，打开 *Webhook 详情* 视图。
2. 此视图提供的信息可用于排查 webhook 订阅问题。
   * 如需了解详情，请参阅下方的 *事件参考* 。

<details>

<summary>事件参考</summary>

| 筛选条件       | 说明                                                                                                                                      |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| 类型         | Webhook [事件类型](https://integrations.impact.com/integration-guides/for-brands/advocate/advocate-api/api-webhooks-for-advocate-programs). |
| Webhook ID | Webhook 的唯一标识符。                                                                                                                         |
| 创建日期       | Webhook 的创建日期。                                                                                                                          |
| 事件数据       | Webhook [负载](https://integrations.impact.com/integration-guides/for-brands/advocate/advocate-api/api-webhooks-for-advocate-programs).   |
| 订阅         | Webhook 发送到的订阅及其状态。                                                                                                                     |
| 订阅详情       | 有关从 Webhook 订阅端点收到的响应的详细信息。详细信息可包括 Webhook 的投递尝试记录，其中显示尝试时间戳、从目标端收到的 HTTP 状态码，以及是否因请求等待目标服务器响应的时间过长而超时。                                 |

</details>

**失败事件投递的 Webhook 重试机制**

* 事件触发后，Rest hook 会立即投递。如果端点未能成功响应某次投递尝试（即返回非 200 状态码），则该次投递将被视为失败。
* 投递失败后，每隔一小时会重试一次，直到投递成功或重试 72 次为止（按每小时重试一次计算，约为 3 天）。
* 持续返回错误的 Webhook 端点将在发生以下次数的错误后自动禁用：

  | 状态码    | 收到的错误次数 |
  | ------ | ------- |
  | 4xx 错误 | 1000    |
  | 5xx 错误 | 2000    |
  | 3xx 错误 | 2000    |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/advocate-program-settings/create-and-manage-advocate-webhook-subscriptions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
