> 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/scraping/web-scraper-api/integrations/webhook-integration.md).

# Webhook Integration

Description of Webhook Integration Function

With the Webhook integration function, you can automatically send notifications to a specified system when specific events occur in Thordata Web Scraper crawling tasks, allowing you to monitor task status in real-time or push data to other services. Webhook supports dynamic data injection, facilitating subsequent automated processing or business linkage.

**Integration Configuration:**

1. **Integration Function Name**\
   Used to identify and manage this Webhook configuration. It is recommended to customize a clear and understandable name for easy subsequent viewing and maintenance.
2. **Event Types**\
   You can set up trigger notifications for the following task events:

   **·** In Progress: The task is being executed

   **·** Task Success: The crawling task has been successfully completed and results are returned

   **·** Task Failure: The crawling task returned no data or an error occurred
3. **Notification Sending Method**\
   When the selected event occurs, the system will send an HTTP POST request to the URL you set. The request body is in JSON format, and its content can be customized with event data dynamically injected through variables.

① **Payload**\
Format: The payload template must be a valid JSON string, and variables can be referenced using double curly braces `{{ }}`. Example:

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

② **Available Variables:**

<table><thead><tr><th width="170">Variable</th><th width="182">Type</th><th>Description</th></tr></thead><tbody><tr><td>userId</td><td>string</td><td>Thordata user ID triggering the event</td></tr><tr><td>createdAt</td><td>string</td><td>Webhook trigger time (ISO format)</td></tr><tr><td>eventType</td><td>string</td><td>Type of triggered event</td></tr><tr><td>eventData</td><td>Object</td><td>Contextual data related to the event</td></tr><tr><td>resource</td><td>Object</td><td>Detailed event resource info (e.g. links)</td></tr><tr><td>globals</td><td>Object</td><td>Current event date (ISO 8601 format)</td></tr></tbody></table>

③ **Example:**

```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"
  }
}

```

**Field Mappings:**

<table><thead><tr><th width="337">Description</th><th>Variable</th></tr></thead><tbody><tr><td>User ID</td><td>userId</td></tr><tr><td>Account ID</td><td>userName</td></tr><tr><td>Creation Time</td><td>createdAt</td></tr><tr><td>Status (success/fail)</td><td>eventType</td></tr><tr><td>Event Context Data</td><td>eventData</td></tr><tr><td>Product Unique ID</td><td>prodect_id</td></tr><tr><td>API Run ID</td><td>apiRunId</td></tr><tr><td>Resource</td><td>resource</td></tr><tr><td>Task ID</td><td>taskId</td></tr><tr><td>Scraping Parameters</td><td>url</td></tr><tr><td>Token</td><td>apiKey</td></tr><tr><td>API URL</td><td>apiUrl</td></tr><tr><td>API Response Code</td><td>apiCode</td></tr><tr><td>Response Time (ms)</td><td>apiResponseTime</td></tr><tr><td>API Error Message</td><td>apiErrorMsg</td></tr><tr><td>API Result</td><td>apiResult</td></tr><tr><td>Error Count</td><td>errorNumber</td></tr><tr><td>Success Rate</td><td>successRate</td></tr><tr><td>Run Time (seconds)</td><td>runseconds</td></tr><tr><td>Task Detail</td><td>detail</td></tr><tr><td>Data Transfer (MB)</td><td>flow</td></tr><tr><td>File Size</td><td>fileSize</td></tr><tr><td>Type</td><td>type</td></tr><tr><td>CSV Download URL</td><td>csvUrl</td></tr><tr><td>JSON Download URL</td><td>jsonUrl</td></tr><tr><td>Audio Download URL</td><td>audioUrl</td></tr><tr><td>Video Download URL</td><td>videoUrl</td></tr><tr><td>Subtitle Download URL</td><td>subtitleUrl</td></tr><tr><td>Task Created At</td><td>createdAt</td></tr><tr><td>Task Finished At</td><td>finishedAt</td></tr></tbody></table>

4. **Headers Template (Optional)**\
   The headers template is a JSON-like string where you can add additional information to the default headers of webhook requests. You can pass variables in the same way as in the payload template (including using string interpolation and available variables). The generated headers must be a valid JSON object, and values can only be strings.

Please note that the following keys are hard-coded and will always be overwritten:

* `Host`: Request URL
* `Content-Type`: application/json
* `Webhook`: Tasks value
* `Webhook-Dispatch-Id`: Tasks ID
* `Request-Origin`

For further assistance, please contact us at <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:

```
GET https://doc.thordata.com/doc/scraping/web-scraper-api/integrations/webhook-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
