NATSotp.code.request请求发送 OTP
Try it 面板需要启用 JavaScript。
向手机号 / 邮箱发送验证码:存码于库、发布 otp.send.requested 事件,并返回挑战工单。
Request Payload
消息格式:JSON
| Name | Data Type | Required | Description |
|---|---|---|---|
| channel | string | Yes | phone / email |
| target | string | Yes | 手机号或邮箱 |
| scene | string | Yes | 用途:login / register / bind |
type RequestBody = {
/** phone / email */
channel: string
/** 手机号或邮箱 */
target: string
/** 用途:login / register / bind */
scene: string
}{
"channel": "email",
"target": "chen.lin@example.com",
"scene": "login"
}Response Payload
回复使用统一信封 {id, code, messages, result},其 result:
| Name | Data Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | 挑战工单(校验时携带) |
| expiresAt | string | Yes | 验证码有效期 |
type ResponseBody = {
/** 挑战工单(校验时携带) */
ticketId: string
/** 验证码有效期 */
expiresAt: string
}{
"ticketId": "cpt_7d92ab41e0583c6f",
"expiresAt": "2026-10-14T18:10:00Z"
}Response Code
回复使用统一信封 {id, code, messages, result},其 code 字段:
| code | Meaning | Notes |
|---|---|---|
| 0 | 成功 | 请求发送 OTP |
| 2201 | 发送频率受限 | 单目标窗口频控 |
Examples
{ "channel": "email", "target": "chen.lin@example.com", "scene": "login" }
{
"id": "01JD8SVBF7Q3S0TP",
"code": 0,
"messages": [],
"result": { "ticketId": "cpt_7d92ab41e0583c6f", "expiresAt": "2026-10-14T18:10:00Z" }
}
Remarks
验证码本体不进任何响应,只随投递渠道到达用户。