/gate/otp/verifyVerify OTP
Verifies a one-time password previously sent to the end-user's email and, on success, issues a Gate JWT and refresh token.
Returns K9O_OTP_EXPIRED (410) if the code is expired or already used, or K9O_INVALID_CREDENTIALS (401) if the code is incorrect.
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| email * | string <email> | The address the code was sent to. |
| code * | string | The 6-digit code from the email. Only the latest code for this address and purpose counts; it expires after 5 minutes and dies after 5 wrong guesses. |
| purpose | "signin" | "magic_link" | "password_reset" | "mfa_challenge" | What the code is for. Default A code is checked against requests with the same purpose only. Send the same purpose as the request. |
| HTTP | K9O Code | Description |
|---|---|---|
| 200 | Success | |
| 401 | K9O_INVALID_CREDENTIALS | The OTP code you entered does not match. Check the code and try again. |
| 404 | K9O_END_USER_NOT_FOUND | No account was found for the provided identity. |
| data * | any | For purpose For any other purpose, neither. |
| One of: object | ||
| verified * | true | Always |
| session * | object | The tokens for the new session. Keep the refresh token for |
| accessToken * | string | A signed JWT that authenticates the end user to this project's API. Send it as Its subject ( It lives for the project's end-user access token lifetime: 30 minutes by default, settable from 5 to 60 minutes. It cannot be revoked early: signing out or revoking sessions stops the next refresh, but a token already issued stays valid until |
| refreshToken * | string | An opaque secret (43 base64url characters) that gets a new access token from Store it securely and never send it anywhere else. It is single use: every refresh returns a new refresh token, and sending the one it replaced a second time ends the whole session. It stops working when the session ends: on sign-out, a password reset, a revoke-all, or when the project's session limits are reached (by default 30 days without a refresh, or 90 days after sign-in, whichever comes first). |
| expiresAt * | string <date-time> | When Refresh before this time to keep the end user signed in. |
| endUserId * | string | The end user the code belongs to ( |
| or: object | ||
| verified * | true | Always |
| mfa * | object | Present instead of |
| required * | true | Always |
| challengeId * | string | An opaque, single-use id for this sign-in (43 base64url characters). Send it with a current code from the end user's authenticator app to A new sign-in by the same door replaces it, and it dies after 5 wrong codes. |
| expiresAt * | string <date-time> | When the challenge expires, 5 minutes after it was issued. After that the end user signs in again. |
| methodsAvailable * | "totp"[] | The second factors that can answer this challenge. Always |
| resident * | object | Where the challenge lives. |
| region * | string | The region that holds the end user and this challenge. |
| origin * | string | That region's API origin. Send the challenge answer here: no other region has the challenge. |
| endUserId * | string | The end user the code belongs to ( |
| or: object | ||
| verified * | true | Always |
| endUserId | string | The end user the code belongs to ( Absent when the address belongs to no active end user. |
| meta * | any | Request metadata: cost, timing and the request and trace ids. |
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.gate.passwordless.verifyOtp({
email: '[email protected]',
code: 'string',
purpose: 'signin'
})Showing example in TypeScript
{
"email": "[email protected]",
"code": "string",
"purpose": "signin"
}{
"data": {
"verified": true,
"session": {
"accessToken": "string",
"refreshToken": "string",
"expiresAt": "string"
},
"endUserId": "string"
}
}