POST/api/v1/otp/verify校验验证码
Try it 面板需要启用 JavaScript。
校验用户收到的验证码,换取一次性已验证工单(verifyTicket),供注册 / 登录 / 绑定回源消费。api_service 编排 otp_service 的 otp.code.verify。
Request
| Name | Data Type | Required | Description |
| Content-Type | string | Yes | 请求体内容类型(默认值 "application/json") |
type RequestHeaders = {
/** 请求体内容类型,默认值 "application/json" */
Content-Type: string
}
{
"Content-Type": "application/json"
}
Body
| Name | Data Type | Required | Description |
| ticketId | string | Yes | 挑战工单(otp/send 返回) |
| code | string | Yes | 用户收到的验证码 |
type RequestBody = {
/** 挑战工单(otp/send 返回) */
ticketId: string
/** 用户收到的验证码 */
code: string
}
{
"ticketId": "cpt_7d92ab41e0583c6f",
"code": "582914"
}
Response
Body
| Name | Data Type | Required | Description |
| verifyTicketId | string | Yes | 已验证工单(一次性) |
| channel | string | Yes | 通道:phone / email |
| target | string | Yes | 验证目标 |
type ResponseBody = {
/** 已验证工单(一次性) */
verifyTicketId: string
/** 通道:phone / email */
channel: string
/** 验证目标 */
target: string
}
{
"verifyTicketId": "otv_8a24de63b917c05f",
"channel": "email",
"target": "chen.lin@example.com"
}
HTTP Code
| HTTP Status |
Meaning |
Notes |
| 200 |
成功 |
返回已验证工单 |
| 400 |
校验失败 |
工单无效或验证码错误 |
| 429 |
尝试次数超限 |
单码校验次数用尽,须重新发送 |
Response Code
响应使用统一信封 {id, code, messages, result},其 code 字段:
| code |
Meaning |
Notes |
| 0 |
成功 |
返回已验证工单 |
| 2202 |
工单无效 |
不存在或已过期 |
| 2203 |
验证码错误 |
与预期不符;单码最大校验次数用尽作废,同样返回 2203 |
Examples
POST /api/v1/otp/verify
Content-Type: application/json
{
"ticketId": "cpt_7d92ab41e0583c6f",
"code": "582914"
}
{
"id": "01JD8SXIUS9W1XT",
"code": 0,
"messages": [],
"result": {
"verifyTicketId": "otv_8a24de63b917c05f",
"channel": "email",
"target": "chen.lin@example.com"
}
}
同一挑战工单只成功校验一次;已验证工单在下游(注册 / 登录 / 绑定)回源消费后立即失效,不可重放。