---
title: "理解“通知” 中的 Webhook包含的负载"
language: "zh"
url: "https://docs.testany.io/zh/docs/understanding-the-payload-of-a-notification-webhoo/"
markdown_url: "https://docs.testany.io/zh/docs/understanding-the-payload-of-a-notification-webhoo.md"
translation: "https://docs.testany.io/en/docs/understanding-the-payload-of-a-notification-webhoo.md"
last_updated: "2026-03-27T10:57:06+08:00"
---

# 理解“通知” 中的 Webhook包含的负载

Testany 通知系统当前会通过 Webhook 分发 发送如下精简 JSON 负载。
这个 webhook body 对应的是当前 `Notification Gateway -> mailman-plugin` 对执行事件数据的投影。
当前顶层字段固定为：

- `name`
- `status`
- `trigger_key`
- `trigger_id`
- `trigger_instance_key`
- `trigger_method`
- `trigger_owner`
- `pipelines`
- `payload`

[视频](https://customer-en3hmhs3okg5hi37.cloudflarestream.com/210d7c7b24f41b9e345b151ce0c62ed0/watch)

### 表 1：负载请求的基本信息

|  |  |
| --- | --- |
| **HTTP 版本** | HTTP/1.1 |
| **请求方法** | POST，符合 RFC2616 |
| **TLS 验证** | 严格，如果提供 |
| **MIME 类型** | `application/json` |
| **超时** | 15 秒 |
| **重试** | 3 次 |
| **主体** | 见表 2 |

### 表 2：负载主体数据格式

| **键** | **类型** | **说明** | **示例** |
| --- | --- | --- | --- |
| `name` | 字符串 | 触发器资源的名称。 | `"notification-demo-payload"` |
| `status` | 整数 | 触发实例的执行状态码。对“执行完成”通知，常见终态值有 `1` 成功、`2` 失败、`3` 跳过、`5` 已取消、`99` 错误。历史或非终态值还可能出现 `-1` 未开始、`0` 运行中。 | `1` |
| `trigger_key` | 字符串 | 触发器资源的键。 | `"P-ABC-0001"` |
| `trigger_id` | 字符串 | 该触发器资源下某次具体触发实例的标识符。 | `"033CE"` |
| `trigger_instance_key` | 字符串 | 具体触发实例的键。 | `"P-ABC-0001-033CE"` |
| `trigger_method` | 字符串，枚举 | 指示触发器类型。枚举：`plan`、`gatekeeper`、`manual_trigger`。 | `"plan"` |
| `trigger_owner` | []字符串 | 触发器资源所有者的列表。 | `["john.doe@acme.tld"]` |
| `pipelines` | []管道 | 执行的管道列表。 | 见表 3 |
| `payload` | 字符串 | 从触发源透传下来的可选自定义负载，按原样作为字符串传递；如果没有自定义负载，则为空字符串。 | `"opaque-string-payload"` |

### 表 3：管道数据格式

| **键** | **类型** | **说明** | **示例** |
| --- | --- | --- | --- |
| `name` | 字符串 | 管道的名称 | `"demo-for-event"` |
| `status` | 整数 | 管道执行状态码。常见终态值有 `1` 成功、`2` 失败、`3` 跳过、`5` 已取消、`99` 错误。非终态值还可能出现 `-1` 未开始、`0` 运行中。 | `1` |
| `key` | 字符串 | 管道的键。 | `"ABC-0001"` |
| `owner` | []字符串 | 管道所有者的列表。 | `["john.doe@acme.tld"]` |
| `cases` | []案例 | 管道使用的案例执行结果列表。 | 见表 4 |
| `duration` | 整数 | 管道执行的持续时间，单位为 `秒` | `22` |
| `execution_key` | 字符串 | 管道执行标识符。 | `"ABC-0001-033CE"` |
| `start_time` | 字符串，时间戳 | RFC3339 时间戳，指示管道执行的开始时间。 | `"2006-01-02T15:04:05Z"` |
| `finish_time` | 字符串，时间戳 | RFC3339 时间戳，指示管道执行的结束时间。 | `"2006-01-02T15:04:05Z"` |

### 表 4：案例数据格式

| **键** | **类型** | **说明** | **示例** |
| --- | --- | --- | --- |
| `name` | 字符串 | 测试案例的名称 | `"check-notification-active"` |
| `status` | 整数 | 测试案例执行状态码。常见终态值有 `1` 通过、`2` 失败、`3` 跳过、`4` 预期失败、`5` 已取消、`99` 错误。非终态值还可能出现 `-1` 未开始、`0` 运行中。 | `1` |
| `case_index` | 整数 | 该案例执行在管道执行详情中的从 `0` 开始的位置索引。可与 `execution_key` 组合使用以打开对应的案例执行日志。 | `0` |
| `key` | 字符串 | 测试案例的键。 | `"00000000"` |
| `runtime_uuid` | 字符串 | 执行案例的运行时实例的唯一标识符。 | `"00000000-0000-0000-0000-000000000000"` |
| `runtime_name` | 字符串 | 执行案例的运行时实例的唯一名称。 | `"CloudPrime-Default"` |
| `owner` | []字符串 | 测试案例所有者的列表。 | `["john.doe@acme.tld"]` |
| `duration` | 整数 | 测试案例执行的持续时间，单位为 `秒` | `6` |
| `env` | 字符串 | 测试案例的环境。 | `"DEMO"` |
| `start_time` | 字符串，时间戳 | RFC3339 时间戳，指示测试案例执行的开始时间。 | `"2006-01-02T15:04:05Z"` |
| `finish_time` | 字符串，时间戳 | RFC3339 时间戳，指示测试案例执行的结束时间。 | `"2006-01-02T15:04:05Z"` |

### 示例

计划任务执行结果通知样例

```json
{
  "name": "notification-demo-payload",
  "pipelines": [
    {
      "cases": [
        {
          "case_index": 0,
          "duration": 6,
          "env": "DEMO",
          "finish_time": "2006-01-02T15:04:05Z",
          "key": "00000000",
          "name": "check-notification-active",
          "owner": [
            "john.doe@acme.tld"
          ],
          "start_time": "2006-01-02T15:04:05Z",
          "status": 1,
          "runtime_uuid": "00000000-0000-0000-0000-000000000000",
          "runtime_name": "CloudPrime-Default"
        }
      ],
      "duration": 22,
      "execution_key": "ABC-0001-033CE",
      "finish_time": "2006-01-02T15:04:05Z",
      "key": "ABC-0001",
      "name": "demo-for-event",
      "owner": [
        "john.doe@acme.tld"
      ],
      "start_time": "2006-01-02T15:04:05Z",
      "status": 1
    }
  ],
  "payload": "opaque-string-payload",
  "status": 1,
  "trigger_key": "P-ABC-0001",
  "trigger_id": "033CE",
  "trigger_instance_key": "P-ABC-0001-033CE",
  "trigger_method": "plan",
  "trigger_owner": [
    "john.doe@acme.tld"
  ]
}
```

门卫执行结果通知样例

```json
{
  "name": "notification-demo-payload",
  "pipelines": [
    {
      "cases": [
        {
          "case_index": 0,
          "duration": 6,
          "env": "DEMO",
          "finish_time": "2006-01-02T15:04:05Z",
          "key": "00000000",
          "name": "check-notification-active",
          "owner": [
            "john.doe@acme.tld"
          ],
          "start_time": "2006-01-02T15:04:05Z",
          "status": 1,
          "runtime_uuid": "00000000-0000-0000-0000-000000000000",
          "runtime_name": "CloudPrime-Default"
        }
      ],
      "duration": 22,
      "execution_key": "ABC-0001-033CE",
      "finish_time": "2006-01-02T15:04:05Z",
      "key": "ABC-0001",
      "name": "demo-for-event",
      "owner": [
        "john.doe@acme.tld"
      ],
      "start_time": "2006-01-02T15:04:05Z",
      "status": 1
    }
  ],
  "payload": "opaque-string-payload",
  "status": 1,
  "trigger_key": "G-ABC-0001",
  "trigger_id": "033CE",
  "trigger_instance_key": "G-ABC-0001-033CE",
  "trigger_method": "gatekeeper",
  "trigger_owner": [
    "john.doe@acme.tld"
  ]
}
```

手动触发执行结果通知样例

```json
{
  "name": "manual-rerun-demo",
  "pipelines": [
    {
      "cases": [
        {
          "case_index": 0,
          "duration": 6,
          "env": "DEMO",
          "finish_time": "2006-01-02T15:04:05Z",
          "key": "00000000",
          "name": "check-notification-active",
          "owner": [
            "john.doe@acme.tld"
          ],
          "start_time": "2006-01-02T15:04:05Z",
          "status": 1,
          "runtime_uuid": null,
          "runtime_name": null
        }
      ],
      "duration": 22,
      "execution_key": "ABC-0001-033CE",
      "finish_time": "2006-01-02T15:04:05Z",
      "key": "ABC-0001",
      "name": "demo-for-event",
      "owner": [
        "john.doe@acme.tld"
      ],
      "start_time": "2006-01-02T15:04:05Z",
      "status": 1
    }
  ],
  "payload": "",
  "status": 1,
  "trigger_key": "M-ABC-0001",
  "trigger_id": "033CE",
  "trigger_instance_key": "M-ABC-0001-033CE",
  "trigger_method": "manual_trigger",
  "trigger_owner": [
    "john.doe@acme.tld"
  ]
}
```

## 本页术语

- [Webhook Dispatch](https://docs.testany.io/zh/docs/glossary.md#webhook-dispatch)
- [运行时 (Runtime)](https://docs.testany.io/zh/docs/glossary.md#runtime)
- [环境 (Environment)](https://docs.testany.io/zh/docs/glossary.md#environment)
- [计划任务 (Plan)](https://docs.testany.io/zh/docs/glossary.md#plan)
- [执行 (Execution)](https://docs.testany.io/zh/docs/glossary.md#execution)
- [门卫 (Gatekeeper)](https://docs.testany.io/zh/docs/glossary.md#gatekeeper)
- [手动触发 (Manual Trigger)](https://docs.testany.io/zh/docs/glossary.md#manual-trigger)
