跳到正文

Webhook 历史记录 GET ​

获取某个 Webhook 的入站请求历史,包括发送了什么、渲染成了什么,以及告警是否已成功投递。

端点 ​

GET https://api.pocketalert.app/v1/webhooks/{tid}/history

身份验证 ​

必填

在请求中加入以下任一请求头:

  • Token: <your-api-key> — 从 API 密钥 页面获取
  • Authorization: Bearer <jwt-token> — 来自 登录 接口

请求 ​

路径参数 ​

参数类型必填描述
tidstring✅Webhook 唯一标识符

查询参数 ​

参数类型默认值描述
pageinteger1页码
perinteger50每页条数(最大 200)
statusstring—按结果筛选:success 或 error

请求示例 ​

bash
curl -X GET "https://api.pocketalert.app/v1/webhooks/kblf7mh9j8jjyeh4fx/history?per=25&status=error" \
  -H "Token: your-api-key"
javascript
const tid = 'kblf7mh9j8jjyeh4fx';
const response = await fetch(`https://api.pocketalert.app/v1/webhooks/${tid}/history?per=25`, {
  headers: { 'Token': 'your-api-key' }
});
const history = await response.json();
python
import requests

tid = 'kblf7mh9j8jjyeh4fx'
response = requests.get(
    f'https://api.pocketalert.app/v1/webhooks/{tid}/history',
    headers={'Token': 'your-api-key'},
    params={'per': 25, 'status': 'error'}
)
print(response.json())

响应 ​

成功响应 ​

200 OK

返回分页的请求列表,最新的在前

字段类型描述
requestsarray已记录的请求
totalinteger保留期内的请求总数
pageinteger当前页码
perinteger每页条数
retention_daysinteger你的套餐保留历史的天数(0 表示不限)
webhookobjecttid、name、url、is_active

requests 中的每一项:

字段类型描述
idinteger请求标识符
methodstring发送方使用的 HTTP 方法
source_ipstring调用方 IP 地址
content_typestring请求的内容类型
querystring原始查询字符串
headersobject请求头(敏感信息已脱敏)
bodystring请求负载
sizeinteger负载大小(字节)
statusstringsuccess 或 error
error_codestring失败原因,成功时为空
rendered_messagestring由你的模板生成的消息
message_tidstring已创建消息的标识符,失败时为空
priorityinteger最终确定的告警级别
duration_msinteger处理耗时
created_atstring请求到达的时间
json
{
  "requests": [
    {
      "id": 412,
      "method": "POST",
      "source_ip": "140.82.115.16",
      "content_type": "application/json",
      "query": "",
      "headers": { "User-Agent": "GitHub-Hookshot", "Authorization": "[redacted]" },
      "body": "{\"repository\":{\"name\":\"pocketalert\"}}",
      "size": 38,
      "status": "success",
      "error_code": "",
      "rendered_message": "Push to pocketalert",
      "message_tid": "yrst1db64dbbe7euurpmanhdy",
      "priority": 1,
      "duration_ms": 24,
      "created_at": "18.07.2026 16:45:06"
    }
  ],
  "total": 1,
  "page": 1,
  "per": 50,
  "retention_days": 90,
  "webhook": {
    "tid": "kblf7mh9j8jjyeh4fx",
    "name": "GitHub Push",
    "url": "cs994rqfkk8ljngt",
    "is_active": true
  }
}

错误代码 ​

当 status 为 error 时,error_code 说明失败的原因:

代码含义
inactiveWebhook 已禁用,因此未发送告警
invalid_json负载无法解析为 JSON
empty_message模板解析结果为空字符串,通常是因为负载中不存在对应的 %path%
encryption_failed消息加密失败
save_failed消息存储失败
daily_limit账户已达到每日消息上限。调用返回 429,未发送告警;此处会保留负载和渲染后的消息

错误响应 ​

状态码描述
401未授权:令牌无效或缺失
404未找到:Webhook 不存在

注意事项 ​

保留期

历史记录的保留天数取决于你的套餐(见 retention_days):免费套餐为 7 天,Starter 为 30 天,Medium 为 90 天,Large 为 365 天。超过保留期的请求会被自动删除;当单个 Webhook 的记录超过 1,000 条时,最早的记录也会被自动删除。

隐私

负载会使用你的个人密钥加密存储,与消息内容的加密方式相同。在存储前,Authorization、Cookie 和 API 密钥相关的请求头会被替换为 [redacted]。

Pocket Alert 文档