Skip to main content
POST/gate/invitations/redeem

Redeem 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).

Parameters
projectSlug *path

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

It is unique within the org.

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

displayNamestring

A display name.

It is accepted but not stored.

Responses
HTTPK9O CodeDescription
200Success
400K9O_INVALID_REQUEST_SHAPEThe password supplied during invitation acceptance is shorter than the minimum length required by the request schema.
400K9O_INVALID_FIELD_VALUEThe invitation token is invalid, has expired, or has already been accepted.
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.
409K9O_EMAIL_ALREADY_REGISTEREDAn end-user account with the invited email address already exists.
Response body (200)
data *object

The new end user, signed in.

An invitation sign-up never asks for an authenticator-app code.

redeemed *true

Always true: the account is created with the invitation's role and groups, and the invitation is used up.

user *object

The end user the invitation created.

id *string

The new end user's id (eu_...).

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

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.invitations.redeem({
  token: 'EXAMPLE-invitation-token-not-a-real-secret',
  password: 'correct-horse-battery-staple',
  displayName: 'My Resource'
})

Showing example in TypeScript

Request example
{
  "token": "EXAMPLE-invitation-token-not-a-real-secret",
  "password": "correct-horse-battery-staple",
  "displayName": "My Resource"
}
Response example (200)
{
  "data": {
    "redeemed": true,
    "user": {
      "id": "string",
      "email": "string"
    },
    "session": {
      "accessToken": "string",
      "refreshToken": "string",
      "expiresAt": "string"
    }
  }
}

More in Sign-in & Sessions