> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcliq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Accept or decline an invitation

> Accepts or declines an invitation with its token. Someone without an account sends a
`username` and `password` (and optionally `display_name`): their account is created and
the reply includes a session `token`. Someone with an account must be signed in as the
invited email.

No authentication: anyone can call this. Token is the secret; decision accept|decline; a new person signs up here; an existing account must be signed in as the invited email.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-invitations.yaml post /v1/invitations/accept
openapi: 3.0.3
info:
  title: 'CliqHub API: Invitations'
  version: 1.0.0
  description: >-
    Invitations bring people into an organization (as member, admin or owner) or
    a realm (as

    member, operator or admin). Sending one emails a link; the person previews
    it and accepts

    or declines with the token in the link. Someone without an account sets
    their username and

    password when accepting, and gets a session token back. An invitation is
    `pending` until it

    is accepted, declined, revoked or expires (after 7 days); sending it again
    to the same

    address renews it.
servers:
  - url: https://{host}
    variables:
      host:
        default: cliqhub.io
        description: CliqHub host
security: []
tags:
  - name: Invitations
    description: >-
      Invitations bring people into an organization (as member, admin or owner)
      or a realm (as

      member, operator or admin). Sending one emails a link; the person previews
      it and accepts

      or declines with the token in the link. Someone without an account sets
      their username and

      password when accepting, and gets a session token back. An invitation is
      `pending` until it

      is accepted, declined, revoked or expires (after 7 days); sending it again
      to the same

      address renews it.
paths:
  /v1/invitations/accept:
    post:
      tags:
        - Invitations
      summary: Accept or decline an invitation
      description: >-
        Accepts or declines an invitation with its token. Someone without an
        account sends a

        `username` and `password` (and optionally `display_name`): their account
        is created and

        the reply includes a session `token`. Someone with an account must be
        signed in as the

        invited email.


        No authentication: anyone can call this. Token is the secret; decision
        accept|decline; a new person signs up here; an existing account must be
        signed in as the invited email.
      operationId: POST_v1_invitations_accept
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                token:
                  type: string
                  minLength: 1
                  description: The token from the invitation link.
                decision:
                  type: string
                  enum:
                    - accept
                    - decline
                  description: '`accept` or `decline`.'
                username:
                  type: string
                  description: 'New account only: the username to take.'
                password:
                  type: string
                  description: 'New account only: the password.'
                display_name:
                  type: string
                  description: 'New account only: the display name.'
              required:
                - token
                - decision
            examples:
              new_person:
                summary: New account
                value:
                  token: inv_8f2c…
                  decision: accept
                  username: jdoe
                  password: <a-strong-password>
                  display_name: Jane Doe
              decline:
                value:
                  token: inv_8f2c…
                  decision: decline
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on success.
                  data:
                    type: object
                    properties:
                      decision:
                        type: string
                        enum:
                          - accept
                          - decline
                      user:
                        type: object
                        properties:
                          id:
                            type: string
                          username:
                            type: string
                          status:
                            type: string
                          created:
                            type: boolean
                            description: A new account was created.
                      org:
                        type: object
                        properties:
                          id:
                            type: string
                          slug:
                            type: string
                      realm:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: string
                          slug:
                            type: string
                      membership:
                        type: object
                        properties:
                          role:
                            type: string
                          status:
                            type: string
                      token:
                        type: string
                        description: 'New accounts only: a session token (`cliq_tok_…`).'
              examples:
                accepted:
                  summary: Accepted by a new person
                  value:
                    ok: true
                    data:
                      decision: accept
                      user:
                        id: 2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e
                        username: jdoe
                        status: active
                        created: true
                      org:
                        id: 2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f
                        slug: acme
                      realm: null
                      membership:
                        role: member
                        status: active
                      token: cliq_tok_4f9a…
                declined:
                  summary: Declined
                  value:
                    ok: true
                    data:
                      decision: decline
        '401':
          description: >-
            `sign_in_required`: The invitee already has an account; sign in as
            them and accept again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                sign_in_required:
                  summary: sign_in_required
                  value:
                    ok: false
                    error: Sign in to accept this invite.
                    code: sign_in_required
        '403':
          description: >-
            `email_mismatch`: You are signed in as someone other than the
            invitee.


            `account_deleted`: The invited account was deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                email_mismatch:
                  summary: email_mismatch
                  value:
                    ok: false
                    error: This invite is for a different email address.
                    code: email_mismatch
                account_deleted:
                  summary: account_deleted
                  value:
                    ok: false
                    error: This account was deleted. Contact your admin.
                    code: account_deleted
        '404':
          description: '`not_found`: No invitation has this token.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                not_found:
                  summary: not_found
                  value:
                    ok: false
                    error: Invite not found
                    code: not_found
        '409':
          description: |-
            `not_pending`: The invitation was already used, declined or revoked.

            `conflict`: The chosen username is taken.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                not_pending:
                  summary: not_pending
                  value:
                    ok: false
                    error: This link was already accepted.
                    code: not_pending
                conflict:
                  summary: conflict
                  value:
                    ok: false
                    error: The name jdoe is already taken.
                    code: conflict
        '410':
          description: >-
            `expired`: The invitation has expired. `details.expired_at` says
            when; ask for it to be sent again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                expired:
                  summary: expired
                  value:
                    ok: false
                    error: This link has expired. Ask for it to be sent again.
                    code: expired
        '422':
          description: >-
            `invalid_params`: A new account's username, password or display name
            is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                invalid_params:
                  summary: invalid_params
                  value:
                    ok: false
                    error: >-
                      Username must start with a letter and contain only
                      lowercase letters, numbers, and hyphens
                    code: invalid_params
        '500':
          description: >-
            `internal_error`: An unexpected server fault. Retry later; if it
            persists, report it with the time of the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                internal_error:
                  summary: internal_error
                  value:
                    ok: false
                    error: Internal server error
                    code: internal_error
      security: []
components:
  schemas:
    HubErr:
      type: object
      required:
        - ok
        - error
      description: >-
        Every failure. Route-policy denials (401/403/404, and 400 when neither
        realm_id nor org_id was sent) answer `error` as `{ code, message }`;
        errors raised by the endpoint answer `error` as the message with the
        code beside it in `code`. Every error has a code. See
        [Errors](/hub-api/errors).
      properties:
        ok:
          type: boolean
          description: Always false on error
        error:
          description: The message, or `{ code, message }` for an access denial.
          oneOf:
            - type: string
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                message:
                  type: string
        code:
          type: string
          description: Stable error code of an endpoint error.
        details:
          type: object
          additionalProperties: true
          description: Structured detail, when there is some.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.