# Redeem Invitation

`POST /gate/invitations/redeem` · Identity & Access · Sign-in & Sessions

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

| Name | In | Required | Description |
|---|---|---|---|
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `token` | string | yes | 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 | yes | The new end user's password, at least 12 characters. A password found in known data breaches is refused. |
| `displayName` | string | no | A display name. It is accepted but not stored. |

```json
{
  "token": "EXAMPLE-invitation-token-not-a-real-secret",
  "password": "correct-horse-battery-staple",
  "displayName": "My Resource"
}
```

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | The new end user, signed in. An invitation sign-up never asks for an authenticator-app code. |
| `data.redeemed` | enum (true) | yes | Always `true`: the account is created with the invitation's role and groups, and the invitation is used up. |
| `data.user` | object | yes | The end user the invitation created. |
| `data.user.id` | string | yes | The new end user's id (`eu_...`). |
| `data.user.email` | string | yes | The invited address, which becomes the end user's email. |
| `data.session` | object | yes | The tokens for the new session. Keep the refresh token for `POST /@{projectSlug}/gate/refresh` and send the access token on API calls. |
| `data.session.accessToken` | string | yes | 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`. |
| `data.session.refreshToken` | string | yes | 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). |
| `data.session.expiresAt` | string (date-time) | yes | When `accessToken` expires. Refresh before this time to keep the end user signed in. |
| `meta` | object | yes | Request metadata: cost, timing and the request and trace ids. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 400 | `K9O_INVALID_REQUEST_SHAPE` | The password supplied during invitation acceptance is shorter than the minimum length required by the request schema. |
| 409 | `K9O_EMAIL_ALREADY_REGISTERED` | An end-user account with the invited email address already exists. |
| 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. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/gate/invitations/redeem' \
  -H 'Content-Type: application/json' \
  -d '{
  "token": "EXAMPLE-invitation-token-not-a-real-secret",
  "password": "correct-horse-battery-staple",
  "displayName": "My Resource"
}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/gate/invitations/redeem', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
  "token": "EXAMPLE-invitation-token-not-a-real-secret",
  "password": "correct-horse-battery-staple",
  "displayName": "My Resource"
}),
});
const { data, meta } = await res.json();
```

### @k9o/core

```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'
})
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/identity-access/redeem-invitation
