/gate/invitations/redeemRedeem Invitation
Accepts a pending end-user invitation by presenting the single-use invitation token.
On success, the invitee is provisioned as an end-user (creating an eu_-prefixed record if first-time) and the inv_-prefixed invitation record is marked accepted.
Invitation tokens have a 7-day TTL and are single-use; an expired token returns K9O_INVITATION_EXPIRED (410).
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| token * | string | The token from the invitation link. It works once, until the invitation expires (7 days by default, as set when it was created). |
| password * | string | The new end user's password, at least 12 characters. A password found in known data breaches is refused. |
| displayName | string | A display name. It is accepted but not stored. |
| HTTP | K9O Code | Description |
|---|---|---|
| 200 | Success | |
| 400 | K9O_INVALID_REQUEST_SHAPE | The password supplied during invitation acceptance is shorter than the minimum length required by the request schema. |
| 400 | K9O_INVALID_FIELD_VALUE | The invitation token is invalid, has expired, or has already been accepted. |
| 400 | K9O_PASSWORD_COMPROMISED | The 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. |
| 409 | K9O_EMAIL_ALREADY_REGISTERED | An end-user account with the invited email address already exists. |
| data * | object | The new end user, signed in. An invitation sign-up never asks for an authenticator-app code. |
| redeemed * | true | Always |
| user * | object | The end user the invitation created. |
| id * | string | The new end user's id ( |
| email * | string | The invited address, which becomes the end user's email. |
| 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. |
| 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.invitations.redeem({
token: 'EXAMPLE-invitation-token-not-a-real-secret',
password: 'correct-horse-battery-staple',
displayName: 'My Resource'
})Showing example in TypeScript
{
"token": "EXAMPLE-invitation-token-not-a-real-secret",
"password": "correct-horse-battery-staple",
"displayName": "My Resource"
}{
"data": {
"redeemed": true,
"user": {
"id": "string",
"email": "string"
},
"session": {
"accessToken": "string",
"refreshToken": "string",
"expiresAt": "string"
}
}
}