Webhook

和设置页面管理的是同一批 Webhook,只是改用初始化脚本来操作。它们发送什么、如何验证,见 Webhook 指南。

列出 Webhook

GET /api/v1/webhooks
Scope: webhooks:read

Response:
[
  {
    "id": "w7c4m2t9xk5b8q1h",
    "name": "CI notifier",
    "type": "http",
    "url": "https://ci.acme.dev/hooks/mailclutch",
    "is_enabled": true,
    "sandbox": { "id": "k3n8x2p9qa7c1m4z", "name": "Acme — staging" },
    "last_triggered_at": "2026-09-02T09:14:23.000000Z",
    "created_at": "2026-08-20T16:02:11.000000Z"
  }
]

对于组织内所有沙箱都会触发的 Webhook,sandbox 为 null。这里从不返回签名密钥。

创建 Webhook

POST /api/v1/webhooks
Scope: webhooks:write
Idempotency-Key: <recommended>

{
  "name": "CI notifier",
  "type": "http",
  "url": "https://ci.acme.dev/hooks/mailclutch",
  "sandbox_id": "k3n8x2p9qa7c1m4z"
}

Response, 201:
{
  "webhook": { …as listed above… },
  "secret": "3kd9…"
}
创建 Webhook 时接受的字段
字段取值
name必填,最多 100 个字符
typehttp(默认)或 slack
url必填,仅限 HTTPS,最多 2048 个字符
sandbox_id可选。令牌能访问的某个沙箱;省略或设为 null 表示整个组织

secret 只显示一次。请保存好:每次投递都用它签名,Webhook 指南说明了如何验证签名。Slack Webhook 没有密钥,URL 本身就是凭据。

更新或删除 Webhook

PATCH /api/v1/webhooks/{id}
Scope: webhooks:write

{ "is_enabled": false }
{ "name": "…", "url": "https://…", "sandbox_id": null }

Response: the webhook

DELETE /api/v1/webhooks/{id}
Scope: webhooks:write
→ { "deleted": true }

{id} 是 Webhook 的 id,即列表中显示或创建时返回的那个值。只需发送要修改的字段。停用会保留 Webhook 及其历史记录;删除则两者一并移除。

投递历史

GET /api/v1/webhooks/{id}/deliveries
Scope: webhooks:read

Response, the last 50:
[
  { "id": "d2r8v5n1jx6p3k9w", "success": true,  "response_code": 200, "duration_ms": 84,   "error": null, "created_at": "…" },
  { "id": "d9h4s7b2mq5t8c1z", "success": false, "response_code": 503, "duration_ms": 3012, "error": "Server error", "created_at": "…" }
]

与设置页面显示的是同样的记录。连续失败通常说明接收端点当时宕机了;Webhook 会按自己的重试计划继续尝试。