Skip to main content
POST/gate/otp/request

Request 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.

Parameters
projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
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 signin, the only purpose whose verify signs the end user in.

A code is checked against requests with the same purpose only.

Responses
HTTPK9O CodeDescription
200Success
404K9O_END_USER_NOT_FOUNDNo account was found for the provided identity.
Response body (200)
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 (euoc_...).

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.

debugCodestring

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.

TypeScript
// 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

Request example
{
  "email": "[email protected]",
  "purpose": "signin"
}
Response example (200)
{
  "data": {
    "otp": {
      "id": "string",
      "expiresAt": "string"
    },
    "debugCode": "string"
  }
}

More in Sign-in & Sessions