切换主题
响应与错误
以下约定适用于 Hook 的 v2 JSON 接口。附件内容、头像等二进制响应使用各自的内容类型。
{3 项}
"ok": true,
"data": {1 项},
"state": "ready"
},
"meta": {2 项}
"api_version": "2",
"request_id": "req_42"
}
}
{3 项}
"ok": false,
"error": {3 项},
"code": "invalid_argument",
"message": "Invalid target",
"retry": "safe"
},
"meta": {2 项}
"api_version": "2",
"request_id": "req_43"
}
}
| 字段 | 类型 | 含义 |
|---|---|---|
ok | boolean | 此次 HTTP API 是否成功处理。 |
data | object | 成功时返回,结构见各接口。 |
error.code | string | 失败分支使用的机器可读错误码。 |
error.message | string | 排查用文字,内容可随版本变化。 |
error.retry | string | safe 可在修正问题后再试,after_check 须先核对状态,never 表示本次动作不要自动重试。 |
meta.api_version、meta.request_id | string | API 版本和诊断请求号。 |
| HTTP | 常见错误码或状态 | 调用方处理 |
|---|---|---|
| 200 | ready、valid、validated 等 | 按接口读取数据。 |
| 202 | queued、accepted 或 pending | 查询类可按接口再次读取状态。发送类先核对微信结果。 |
| 400 | invalid_argument、owner_mismatch | 检查字段、目标和账号。 |
| 401 | unauthorized | 检查 Bearer token 是否属于当前实例。 |
| 404 | not_found、reference_not_found | 检查资源 ID、会话和缓存是否有效。 |
| 409 | busy、account_offline、session_changed、applet_metadata_required、action_unavailable | 按接口补资料、等待、登录或重建会话。 |
| 413 | request_too_large | 缩小请求体。 |
| 422 | native_rejected、reference_not_allowed | 核对微信状态或原消息的引用资格。 |
| 501 | not_supported | 检查该版本的能力或允许的输入类型。 |
| 503 | service_unavailable | 检查实例是否已就绪或故障。 |
| 504 | outcome_unknown | 核对实际结果后再决定是否再次调用。 |
发送接口的 HTTP 202 表示本机受理,delivery=unconfirmed 表示送达尚未确认。对发送、收款和红包操作,连接超时同样可能已经产生副作用。
消息 ID、wxid、群 ID 和事件游标按字符串处理。联系人列表使用 cursor,事件流使用 after,均从对应接口返回的 next_cursor 继续。时间字段按命名区分 Unix 秒和毫秒。