> For the complete documentation index, see [llms.txt](https://doc.thordata.com/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.thordata.com/doc/zh/web-scraper-api/ji-cheng/webhook-ji-cheng.md).

# Webhook 集成

Webhook 集成功能说明

通过 Webhook 集成功能，您可以在 Thordata Web Scraper 抓取任务中发生特定事件时，自动向指定系统发送通知，从而实时监控任务状态或将数据推送到其他服务。Webhook 支持动态数据注入，方便后续的自动化处理或业务联动。

#### 集成配置：

**1. 集成功能名称**

用于识别和管理该 Webhook 配置。建议自定义一个清晰易懂的名称，方便后续查看和维护。

***

**2. 事件类型**

您可以为以下任务事件设置触发通知：

* **运行中**：任务正在执行中
* **任务成功**：抓取任务已成功完成并返回结果
* **任务失败**：抓取任务未返回任何数据或发生错误

***

**3. 发送通知的方式**

当选定事件发生时，系统将向您设置的 URL 发送一条 HTTP POST 请求，请求体为 JSON 格式，内容可以自定义，并通过变量动态注入事件数据。

**① 有效负载（Payload）**

格式说明：Payload 模板必须是合法的 JSON 字符串，并可使用双花括号 {{ }} 引用变量，例如：

```json
{
  "userId": "{{userId}}",
  "eventType": "{{eventType}}",
  "createdAt": "{{createdAt}}",
  "eventData": "{{eventData}}",
  "resource": "{{resource}}"
}
```

**② 可用变量列表：**

<table><thead><tr><th width="167">变量名</th><th width="168">类型</th><th>说明</th></tr></thead><tbody><tr><td>userId</td><td>string</td><td>触发事件的 Thordata 用户 ID</td></tr><tr><td>createdAt</td><td>string</td><td>Webhook 触发时间（ISO 格式）</td></tr><tr><td>eventType</td><td>string</td><td>当前触发的事件类型</td></tr><tr><td>eventData</td><td>Object</td><td>与该事件相关的上下文数据</td></tr><tr><td>resource</td><td>Object</td><td>事件资源的详细数据（如文件链接等）</td></tr><tr><td>globals</td><td>Object</td><td>当前事件日期（ISO 8601 格式）</td></tr></tbody></table>

**③ 示例：**

```sh
{
  "userId": 3406,
  "userName": "Thor84******",
  "createdAt": "2025-06-07T06:33:14Z",
  "eventType": "ACTOR.RUN.SUCCEEDED",
  "eventData": {
    "prodect_id": "3",
    "apiRunId": "2e9ddee0582a********************"
  },
  "resource": {
    "taskId": "2e9ddee0582a********************",
    "url": "{\"spider_errors\":true,\"spider_id\":\"3\",\"spider_parameters\":[{\"url\":\"https://www.amazon.com/dp/B0DPMHRZ1W?th=1\\u0026psc=1\"}]}",
    "apiKey": "289f5c53e47d616********************",
    "apiUrl": "",
    "apiCode": 400,
    "apiResponseTime": 28000,
    "apiErrorMsg": "",
    "apiResult": "",
    "errorNumber": 1,
    "successRate": 0,
    "runseconds": 12340,
    "detail": "Completed! 26 requests in total: 26 successful, 0 failed",
    "flow": 1765,
    "fileSize": 1765,
    "type": 0,
    "csvUrl": "https://th-scrapers-1303252866.cos.na-siliconvalley.myqcloud.com/scrapers/thordata/2025/06/07/2e9ddee0582a40a9****************.csv",
    "jsonUrl": "https://th-scrapers-1303252866.cos.na-siliconvalley.myqcloud.com/scrapers/thordata/2025/06/07/2e9ddee0582a40a9****************.json",
    "audioUrl": "",
    "videoUrl": "",
    "subtitleUrl": "",
    "createdAt": "2025-06-07T14:33:14+08:00",
    "finishedAt": "2025-06-07T14:33:44+08:00"
  }
}

```

**对应字段说明：**

<table><thead><tr><th width="243">字段名</th><th>含义说明</th></tr></thead><tbody><tr><td>userId</td><td>用户 ID</td></tr><tr><td>userName</td><td>用户账户名</td></tr><tr><td>createdAt</td><td>创建时间</td></tr><tr><td>eventType</td><td>状态：成功/失败</td></tr><tr><td>eventData</td><td>事件的相关数据</td></tr><tr><td>prodect_id</td><td>产品唯一编号</td></tr><tr><td>apiRunId</td><td>API 任务 ID</td></tr><tr><td>resource</td><td>资源</td></tr><tr><td>taskId</td><td>任务 ID</td></tr><tr><td>url</td><td>抓取参数</td></tr><tr><td>apiKey</td><td>抓取用的 Token</td></tr><tr><td>apiUrl</td><td>爬虫 API 请求 URL</td></tr><tr><td>apiCode</td><td>爬虫 API 返回状态</td></tr><tr><td>apiResponseTime</td><td>API 响应耗时</td></tr><tr><td>apiErrorMsg</td><td>API 错误信息</td></tr><tr><td>apiResult</td><td>API 返回结果</td></tr><tr><td>errorNumber</td><td>错误次数</td></tr><tr><td>successRate</td><td>成功率</td></tr><tr><td>runseconds</td><td>运行秒数</td></tr><tr><td>detail</td><td>运行细节</td></tr><tr><td>flow</td><td>消耗流量</td></tr><tr><td>fileSize</td><td>文件大小</td></tr><tr><td>type</td><td>抓取类型</td></tr><tr><td>csvUrl</td><td>CSV 下载链接</td></tr><tr><td>jsonUrl</td><td>JSON 下载链接</td></tr><tr><td>audioUrl</td><td>音频下载链接</td></tr><tr><td>videoUrl</td><td>视频下载链接</td></tr><tr><td>subtitleUrl</td><td>字幕下载链接</td></tr><tr><td>finishedAt</td><td>抓取结束时间</td></tr></tbody></table>

***

**4. Headers 模板（可选）**&#x20;

headers 模板是一个类似 JSON 的字符串，您可以在其中向 webhook 请求的默认 header 添加附加信息。您可以像在有效负载模板中一样传递变量（包括使用字符串插值和可用变量）。生成的 headers 必须是有效的json对象，并且值只能是字符串。 请注意，以下键是硬编码的，并且将始终被重写：

可用变量：&#x20;

Host：请求&#x20;

URL Content-Type：application/json&#x20;

Webhook： Tasks 值&#x20;

Webhook-Dispatch-Id： Tasks id&#x20;

Request-Origin

***

如果您需要更多帮助，请通过邮箱<support@thordata.com>联系我们。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.thordata.com/doc/zh/web-scraper-api/ji-cheng/webhook-ji-cheng.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
