列出投递记录
GET /v1/webhooks/deliveries
列出已认证用户最近的 Webhook 投递记录。返回按最新排序的投递日志,便于您监控 Webhook 是否成功接收事件。
试一试
在 Swagger UI 中交互式测试此端点。
需要认证
在 Authorization 头中包含您的 API 密钥。
请求
请求头
| 头 | 值 | 必需 |
|---|---|---|
Authorization | Bearer <token> | 是 |
查询参数
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
webhookId | string | -- | 按特定 Webhook ID 筛选投递记录。 |
limit | number | 50 | 返回的最大结果数(1--100)。 |
代码示例
bash
curl "https://api.docmap.io/v1/webhooks/deliveries?limit=10" \
-H "Authorization: Bearer dm_live_abc123def456ghi789jkl012mno345"typescript
const apiKey = process.env.DOCMAP_API_KEY
const response = await fetch(
'https://api.docmap.io/v1/webhooks/deliveries?limit=10',
{ headers: { 'Authorization': `Bearer ${apiKey}` } },
)
const { data } = await response.json()
for (const delivery of data) {
console.log(`${delivery.event} → ${delivery.url} — ${delivery.status} (${delivery.durationMs}ms)`)
}python
import requests
api_key = "dm_live_abc123def456ghi789jkl012mno345"
response = requests.get(
"https://api.docmap.io/v1/webhooks/deliveries",
headers={"Authorization": f"Bearer {api_key}"},
params={"limit": 10},
)
deliveries = response.json()["data"]
for d in deliveries:
print(f"{d['event']} → {d['url']} — {d['status']} ({d['durationMs']}ms)")响应
状态码:200 OK
响应体包含一个 data 数组,由投递日志对象组成。
字段
数组中每个对象包含:
| 字段 | 类型 | 描述 |
|---|---|---|
id | string | 投递记录的唯一标识符。 |
userId | string | 拥有该 Webhook 的用户 ID。 |
webhookId | string | 目标 Webhook 的 ID。 |
extractionId | string | 触发此投递的提取 ID。 |
event | string | 事件名称:extraction.completed 或 extraction.failed。 |
url | string | 投递时的 Webhook URL。 |
status | string | 端点返回 2xx 状态码时为 success,否则为 failed。 |
httpStatus | number | null | HTTP 响应状态码。如果请求在收到响应前失败(例如网络错误、超时),则为 null。 |
error | string | null | 投递失败时的错误信息。成功时为 null。 |
durationMs | number | 投递尝试的往返时间(毫秒)。 |
createdAt | string | 投递尝试时间的 ISO 8601 时间戳。 |
示例
json
{
"data": [
{
"id": "abc123def456",
"userId": "uid_a1b2c3d4e5f6",
"webhookId": "webhook-abc123def456",
"extractionId": "extract-xyz789",
"event": "extraction.completed",
"url": "https://your-app.com/webhooks/docmap",
"status": "success",
"httpStatus": 200,
"error": null,
"durationMs": 342,
"createdAt": "2025-01-20T14:30:04.000Z"
},
{
"id": "def456ghi789",
"userId": "uid_a1b2c3d4e5f6",
"webhookId": "webhook-abc123def456",
"extractionId": "extract-uvw456",
"event": "extraction.failed",
"url": "https://your-app.com/webhooks/docmap",
"status": "failed",
"httpStatus": null,
"error": "The operation was aborted due to timeout",
"durationMs": 10003,
"createdAt": "2025-01-20T12:15:00.000Z"
}
]
}错误
| 状态码 | 错误码 | 描述 |
|---|---|---|
401 | UNAUTHORIZED | 缺少、无效或已过期的 API 密钥/令牌。 |
