NATSattempt.record记录因素结果并获取尝试工单
Try it 面板需要启用 JavaScript。
懒创建或续用尝试:首个因素验证时创建记录并绑定环境指纹,随后每个因素(无论成败)都经此记录并返回最新工单与状态。
Request Payload
消息格式:JSON
| Name | Data Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | 用户 ID |
| factor | string | Yes | password / otp / mfa / captcha / third-party |
| passed | boolean | Yes | 该因素是否通过 |
| fingerprint | string | Yes | 环境指纹(调用方由 IP / UA 等计算) |
| existingTicketId | string | No | 既有尝试工单(续用场景携带,首因素不携带) |
type RequestBody = {
/** 用户 ID */
userId: string
/** password / otp / mfa / captcha / third-party */
factor: string
/** 该因素是否通过 */
passed: boolean
/** 环境指纹(调用方由 IP / UA 等计算) */
fingerprint: string
/** 既有尝试工单(续用场景携带,首因素不携带) */
existingTicketId?: string
}{
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"factor": "password",
"passed": true,
"fingerprint": "fp_c41a9e07d2b8"
}Response Payload
回复使用统一信封 {id, code, messages, result},其 result:
| Name | Data Type | Required | Description |
|---|---|---|---|
| attemptTicketId | string | Yes | 尝试工单(后续因素继续携带) |
| status | string | Yes | pending 未达标 / satisfied 已达标 |
| score | number | Yes | 当前累加分数 |
| threshold | number | Yes | 阈值 |
| verifiedFactors | array | Yes | 已通过的因素 |
| nextFactors | array | Yes | 仍可选的下一因素 |
| expiresAt | string | Yes | 工单过期时间 |
type ResponseBody = {
/** 尝试工单(后续因素继续携带) */
attemptTicketId: string
/** pending 未达标 / satisfied 已达标 */
status: string
/** 当前累加分数 */
score: number
/** 阈值 */
threshold: number
/** 已通过的因素 */
verifiedFactors: string[]
/** 仍可选的下一因素 */
nextFactors: string[]
/** 工单过期时间 */
expiresAt: string
}{
"attemptTicketId": "atk_9f2c7be14d0a53e8",
"status": "pending",
"score": 40,
"threshold": 60,
"verifiedFactors": [
"password"
],
"nextFactors": [
"otp",
"mfa",
"captcha"
],
"expiresAt": "2026-10-14T08:10:00Z"
}Response Code
回复使用统一信封 {id, code, messages, result},其 code 字段:
| code | Meaning | Notes |
|---|---|---|
| 0 | 成功 | 记录因素结果并获取尝试工单 |
| 2008 | 环境指纹不匹配 | 携带的既有工单与本次指纹不符,拒绝合并 |
| 2007 | 尝试已被冻结 | 连续失败达到上限 |
Examples
{
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"factor": "password",
"passed": true,
"fingerprint": "fp_c41a9e07d2b8"
}
{
"id": "01JD8SVNR9C5E2FB",
"code": 0,
"messages": [],
"result": {
"attemptTicketId": "atk_9f2c7be14d0a53e8",
"status": "pending",
"score": 40,
"threshold": 60,
"verifiedFactors": ["password"],
"nextFactors": ["otp", "mfa", "captcha"],
"expiresAt": "2026-10-14T08:10:00Z"
}
}
Remarks
失败因素也计入记录但不得分。