Skip to main content
POST/gate/password-reset/redeem

Redeem Password Reset

Completes a password reset by accepting the single-use reset token and the new password.

On success, the end-user's password hash is updated, all existing sessions and refresh tokens are revoked, and a fresh Gate JWT is issued.

Returns K9O_PASSWORD_RESET_TOKEN_EXPIRED (410) if the token is expired or already used.

Parameters
projectSlug *path

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

It is unique within the org.

Request body
token *string

The reset code from the email.

It works once and expires one hour after it was sent.

newPassword *string

The new password, at least 12 characters.

A password found in known data breaches is refused.

Responses
HTTPK9O CodeDescription
200Success
400K9O_INVALID_REQUEST_SHAPEThe new password is shorter than the minimum length required by the request schema.
400K9O_INVALID_FIELD_VALUEThe password-reset token is invalid, has expired, or has already been used.
400K9O_PASSWORD_COMPROMISEDThe new password appears in a known data breach at or above the project's threshold (the project's have-i-been-pwned install, with its Gate block on). Choose a different password; context is empty.
404K9O_END_USER_NOT_FOUNDNo end-user record matches the identity associated with the supplied password-reset token.
Response body (200)
data *any

Either session or mfa, never both.

One of: object
redeemed *true

Always true: the password is changed and every earlier session of the end user has ended.

session *object

The tokens for the new session.

Keep the refresh token for POST /@{projectSlug}/gate/refresh and send the access token on API calls.

accessToken *string

A signed JWT that authenticates the end user to this project's API.

Send it as Authorization: Bearer <accessToken>.

Its subject (sub) is the end user's id (eu_...), its audience (aud) is the project id (proj_...), and its issuer is the API origin of the region that holds the end user.

It lives for the project's end-user access token lifetime: 30 minutes by default, settable from 5 to 60 minutes. expiresAt is when it expires.

It cannot be revoked early: signing out or revoking sessions stops the next refresh, but a token already issued stays valid until expiresAt.

refreshToken *string

An opaque secret (43 base64url characters) that gets a new access token from POST /@{projectSlug}/gate/refresh.

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 accessToken expires.

Refresh before this time to keep the end user signed in.

endUserId *string

The end user whose password changed (eu_...).

or: object
redeemed *true

Always true: the password is changed and every earlier session of the end user has ended.

mfa *object

Present instead of session when the end user has a confirmed authenticator app: the sign-in needs a code first.

required *true

Always true: the end user has a confirmed authenticator app, so this sign-in needs a code before it gets a session.

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 POST /@{projectSlug}/gate/mfa/challenge, on the origin in resident.origin, to get the session.

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 ["totp"]: a time-based code from an authenticator app.

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 whose password changed (eu_...).

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.passwordReset.redeem({
  token: 'EXAMPLE-reset-token-not-a-real-secret-0000',
  newPassword: 'correct-horse-battery-staple'
})

Showing example in TypeScript

Request example
{
  "token": "EXAMPLE-reset-token-not-a-real-secret-0000",
  "newPassword": "correct-horse-battery-staple"
}
Response example (200)
{
  "data": {
    "redeemed": true,
    "session": {
      "accessToken": "string",
      "refreshToken": "string",
      "expiresAt": "string"
    },
    "endUserId": "string"
  }
}

More in Sign-in & Sessions