/gate/otp/requestRequest OTP
Sends a 6-digit one-time password to the end-user's email address, initiating a passwordless sign-in or step-up flow.
The OTP code has a 5-minute TTL and is single-use.
Returns 202 Accepted regardless of whether the email matches an existing end-user, preventing enumeration.
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| email * | string <email> | The address to send the code to. The response is the same whether or not an active end user has this address; a code is only emailed when one does. |
| 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. |
| HTTP | K9O Code | Description |
|---|---|---|
| 200 | Success | |
| 404 | K9O_END_USER_NOT_FOUND | No account was found for the provided identity. |
| data * | object | Confirms the request was accepted. When the address belongs to an active end user, the code is emailed to it. |
| otp * | object | The code request. It looks the same whether or not the address belongs to an end user. |
| id * | string | An id for this code request ( Every request gets one, registered address or not. Verify does not need it. |
| expiresAt * | string <date-time> | When the code expires, 5 minutes from now. |
| debugCode | string | The code itself. Only in a test deployment that turns this on; a production deployment never includes it. |
| 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.requestOtp({
email: '[email protected]',
purpose: 'signin'
})Showing example in TypeScript
{
"email": "[email protected]",
"purpose": "signin"
}{
"data": {
"otp": {
"id": "string",
"expiresAt": "string"
},
"debugCode": "string"
}
}