主题
商户 API 错误
POST /v3/merchant/errors
本接口使用 POST /v3/merchant/errors,用于查询过去 7 天返回错误的商户 API 任务。
如果您为任务了 webhook( pingback 或 postback),但由于服务器错误未收到回调,可通过本接口获取任务 ID,再使用 webhook 重发接口重新发送回调。
如果某个任务未出现在结果列表中,表示该任务未返回错误,或任务尚未完成。
计费说明
本接口不收取调用费用,正常响应中的 cost 为 0。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求信息
http
POST https://api.seermartech.cn/v3/merchant/errors
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json所有 POST 请求数据使用 UTF-8 编码的 JSON 格式。请求体是数组,数组中的每个对象代表一组查询条件。
请求参数
| 字段 | 类型 | 填 | 说明 |
|---|---|---|---|
limit | integer | 否 | 返回的错误任务最大数量。默认值:1000;最大值:1000。 |
offset | integer | 否 | 结果数组的偏移量。默认值:0。例如设置为 10 时,跳过前 10 条结果,从第 11 条开始返回。 |
filtered_function | string | 否 | 按 API 函数筛选错误任务。可使用响应中 function 字段的值进行筛选,例如 sellers/ad_url、postback_url、pingback_url。建议获取未筛选结果,再根据的 function 值进行筛选。 |
datetime_from | string | 否 | 错误时间筛选起点。支持过去 7 天的时间范围,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 12:57:46 +00:00。 |
datetime_to | string | 否 | 错误时间筛选终点。支持过去 7 天的时间范围,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 13:57:46 +00:00。 |
请求示例
json
[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]响应结构
接口返回 JSON 数据 tasks 数组查询结果。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。完整状态码列表请参考错误码文档。 |
status_message | string | 请求级状态信息。 |
time | string | 请求总执行时间,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,使用 UUID 格式。 |
status_code | integer | 任务状态码,通常在 10000 至 60000 范围。 |
status_message | string | 任务状态信息。 |
time | string | 任务执行时间,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量。 |
path | array | 请求使用的 URL 路径。 |
data | object | 创建或查询任务时提交的参数。 |
result | array | 错误明细数组。 |
result 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 出错任务的 ID。 |
datetime | string | 错误发生时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00。 |
function | string | 产生错误的 API 函数。 |
error_code | integer | 错误码。 |
error_message | string | 错误信息或导致错误的 URL。 |
http_url | string | 导致错误的 URL,可能是您调用的 API 地址,也可能是 pingback/postback 地址。 |
http_method | string | HTTP 请求方法。 |
http_code | integer | HTTP 状态码。 |
http_time | float | HTTP 请求耗时。对于使用 pingback/postback 的任务,该字段表示您的服务器响应所用时间。 |
http_response | string | HTTP 响应,即服务器返回的原始响应。 |
错误码
响应级和任务级错误码可参考本平台的错误码文档。任务级错误码由本平台生成,通常位于 10000 至 60000 范围。
代码示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/merchant/errors" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/merchant/errors"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
payload = [
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url",
}
]
response = requests.post(url, headers=headers, json=payload)
data = response.json()
if data.get("status_code") == 20000:
print(data)
else:
print(
f"请求失败。错误码:{data.get('status_code')},"
f"错误信息:{data.get('status_message')}"
)TypeScript
typescript
const response = await fetch(
"https://api.seermartech.cn/v3/merchant/errors",
{
method: "POST",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify([
{
limit: 10,
offset: 0,
filtered_function: "pingback_url",
},
]),
}
);
const result = await response.json();
if (result.status_code === 20000) {
// 处理成功响应
console.log(result);
} else {
// 处理接口错误
console.error(
`请求失败。错误码:${result.status_code},错误信息:${result.status_message}`
);
}响应示例
json
{
"version": "0.1.20220321",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1538 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1538 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"merchant",
"errors"
],
"data": {
"api": "merchant",
"function": "errors",
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
},
"result": [
{
"id": "11111111-1111-1111-1111-111111111111",
"datetime": "2021-11-15 13:20:00 +00:00",
"function": "pingback_url",
"error_code": 50000,
"error_message": "服务器响应错误",
"http_url": "https://example.com/pingback",
"http_method": "POST",
"http_code": 500,
"http_time": 0.842,
"http_response": "Internal Server Error"
}
]
}
]
}实用场景
- 排查回调失败任务:筛选
pingback_url或postback_url错误,定位未成功接收回调的任务并执行重发,减少任务结果遗漏。 - 监控第三方接口异常:根据
http_code、http_response和http_time分析外部接口障,及时发现时、5xx 错误等问题。 - 核对任务执行状态:按
datetime_from和datetime_to查询指定时间段的错误任务,支持日常任务质量巡检和障复盘。 - 定位特定 API 函数问题:使用
filtered_function聚合某一接口函数的错误,快速判断问题是否集中在特定业务模块。 - 构建失败任务补偿流程:读取错误记录中的任务 ID 和错误信息,将失败任务接自动重试或人工处理队列,提升数据采集完整性。