# 列出 Webhook 与投递记录

读取端点、订阅事件及最近 100 条投递记录。

GET `/api/settings/webhooks`

- **认证** 控制台会话 Cookie。
- **成功状态** `200`

## 请求参数

| 参数 | 类型 | 位置 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `status` | failed | `query` | 否 | 传入 failed 只返回失败投递，省略时返回所有近期投递。 |

## 请求示例

JavaScript 示例可在本站已登录的浏览器中运行。cURL 和 Python 示例读取你本机的 cookies.txt Cookie 文件。请将会话 Cookie 视为私密凭据。

**cURL**

```bash
curl -i -X GET 'https://social2api.com/api/settings/webhooks?status=failed' \
  --cookie ./cookies.txt
```

**Python**

```python
from urllib.error import HTTPError
from urllib.request import Request, HTTPCookieProcessor, build_opener
from http.cookiejar import MozillaCookieJar

request = Request(
    "https://social2api.com/api/settings/webhooks?status=failed",
    method="GET",
)
cookies = MozillaCookieJar("./cookies.txt")
cookies.load(ignore_discard=True)
send = build_opener(HTTPCookieProcessor(cookies)).open
try:
    with send(request) as response:
        print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
    print(error.code, error.read().decode("utf-8"))
```

**JavaScript**

```javascript
const response = await fetch("/api/settings/webhooks?status=failed", {
  method: "GET",
  credentials: "same-origin",
});
console.log(response.status, await response.text());
```

## 响应

**200 · 示例响应**

```json
{
  "endpoints": [
    {
      "id": "wh_4a5076aa-f9ab-46e6-b383-7b1374392dc4",
      "url": "https://example.com/webhook",
      "events": [
        "tool_run.finished"
      ],
      "enabled": true,
      "createdAt": "2026-01-15T12:00:00.000Z",
      "updatedAt": "2026-01-15T12:00:00.000Z"
    }
  ],
  "deliveries": [],
  "failedCount": 0,
  "deliveryCount": 1,
  "limit": 10,
  "eventTypes": [
    "tool_run.finished",
    "tool_run.failed",
    "batch.finished",
    "schedule_run.finished",
    "schedule.alert",
    "balance.low",
    "daily_cap.reached"
  ]
}
```

**错误示例**

```json
{
  "error": "请先登录。"
}
```

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `endpoints[].id` | string | 端点 ID。 |
| `endpoints[].url` | URI | 端点的接收地址。 |
| `endpoints[].events` | string\[\] | 订阅的事件类型。 |
| `endpoints[].enabled` | boolean | 是否开启自动事件投递。 |
| `endpoints[].createdAt` | ISO 8601 date-time | 端点创建时间。 |
| `endpoints[].updatedAt` | ISO 8601 date-time | 端点上次更新时间。 |
| `deliveries[].id` | string | 投递记录 ID。 |
| `deliveries[].endpointId` | string | 接收端点 ID。 |
| `deliveries[].url` | URI | 投递时使用的端点地址。 |
| `deliveries[].eventId` | string | 事件 ID。同一事件重投时保持一致。 |
| `deliveries[].type` | string | 事件类型。测试投递使用 webhook.test。 |
| `deliveries[].status` | delivered \| failed | 本次投递结果。 |
| `deliveries[].statusCode` | integer \| null | 端点返回的 HTTP 状态。连接失败时为 null。 |
| `deliveries[].error` | string \| null | 失败信息。投递成功时为 null。 |
| `deliveries[].createdAt` | ISO 8601 date-time | 投递时间。 |
| `failedCount` | integer | 近期记录中的失败数，独立于筛选条件。 |
| `deliveryCount` | integer | 近期记录总数，独立于筛选条件。 |
| `limit` | integer | 每个账号最多拥有的端点数。 |
| `eventTypes` | string\[\] | 可以订阅的事件类型。 |

## 错误状态

| HTTP | 原因与处理 |
| --- | --- |
| `401` | 控制台会话缺失、过期或无效。 |
| `405` | 请求方法不受支持。 |
| `503` | 此部署未配置该控制台服务。 |

## 使用细节

-   实时取数会触发工具任务、批处理和额度相关事件。定时事件需要独立调度。

## 同组接口

-   [POST 创建 Webhook 端点](<https://social2api.com/docs/api/webhooks-create/>)
-   [PATCH 更新 Webhook 端点](<https://social2api.com/docs/api/webhooks-update/>)
-   [DELETE 删除 Webhook 端点](<https://social2api.com/docs/api/webhooks-delete/>)
-   [POST 发送 Webhook 测试事件](<https://social2api.com/docs/api/webhooks-test/>)
-   [POST 轮换 Webhook 签名密钥](<https://social2api.com/docs/api/webhooks-rotate/>)

规范页面：<https://social2api.com/docs/api/webhooks-list/>
