Skip to main content

Task System API

异步任务系统,支持任务创建、状态追踪、放弃/重试和 webhook 通知。

Endpoints​

EndpointMethodDescription
/api/v1/task/createPOST创建任务
/api/v1/task/listPOST任务列表
/api/v1/task/detailPOST任务详情
/api/v1/task/cancelPOST放弃任务
/api/v1/task/retryPOST重试任务
/api/v1/task/executePOST重新执行
/api/v1/task/logsPOST任务执行日志
/api/v1/task/testPOST沙盒测试

任务状态​

pending → running → done
→ failed → retry → pending
→ cancelled

创建任务​

POST /api/v1/task/create

{
"type": "waybill_loading_confirm",
"ref_id": "123456",
"webhook": {
"url": "https://example.com/webhook",
"events": ["done", "failed"],
"enabled": true
}
}

Response:

{
"code": 200,
"data": {
"id": "2JxQpF3K8vNqZrLmXwYbT4",
"status": "pending"
}
}

查询结果​

POST /api/v1/task/detail

{ "id": "2JxQpF3K8vNqZrLmXwYbT4" }

接收通知​

创建任务时配置 webhook,任务完成后自动回调:

{
"event": "task.done",
"task_id": "2JxQpF3K8vNqZrLmXwYbT4",
"type": "waybill_loading_confirm",
"ref_id": "123456",
"status": "done"
}

支持事件:done、failed、cancelled


放弃与重试​

放弃:POST /api/v1/task/cancel

{ "id": "2JxQpF3K8vNqZrLmXwYbT4" }

重试(仅 failed):POST /api/v1/task/retry

{ "id": "2JxQpF3K8vNqZrLmXwYbT4" }

已支持的任务类型​

Task Type说明
pickup_confirm取件确认
waybill_confirm面单确认
waybill_loading_confirm装车确认