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

# Invite User

> Sends an invitation email to join the authenticated user's workspace.
Requires admin role. Uses WorkOS invitations if available, otherwise
sends custom email with signup link.




## OpenAPI

````yaml POST /api/users/invite
openapi: 3.1.0
info:
  title: Whilst Slack Bot API
  version: 0.1.0
  description: >-
    Internal endpoints backing the Whilst Slack bot. Includes Slack event
    intake, OAuth install flow, health checks, and admin operations.
servers:
  - url: https://api.staging.whilst.app
    description: Staging
  - url: https://api.whilst.app
    description: Production
security: []
paths:
  /api/users/invite:
    post:
      tags:
        - User Management
      summary: Invite user to workspace
      description: |
        Sends an invitation email to join the authenticated user's workspace.
        Requires admin role. Uses WorkOS invitations if available, otherwise
        sends custom email with signup link.
      operationId: postUsersInvite
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InviteUserRequest'
      responses:
        '200':
          description: Invitation sent successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InviteUserResponse'
        '400':
          description: Invalid request (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized (no session)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden (user is not admin)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: User with this email already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error (email sending failed)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - session_cookie: []
components:
  schemas:
    InviteUserRequest:
      type: object
      required:
        - email
        - role
      properties:
        email:
          type: string
          format: email
          description: Email address of the user to invite
          example: colleague@acme.com
        role:
          type: string
          enum:
            - admin
            - member
          description: Role to assign to the invited user
          default: member
    InviteUserResponse:
      type: object
      required:
        - success
        - message
      properties:
        success:
          type: boolean
        message:
          type: string
        invitationId:
          type: string
          description: WorkOS invitation ID (if available)
        invitationUrl:
          type: string
          format: uri
          description: Direct signup URL (fallback method)
    ErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable error message
        code:
          type: string
          description: Machine-readable error code
        details:
          type: object
          description: Additional error context
  securitySchemes:
    session_cookie:
      type: apiKey
      in: cookie
      name: whilst_session
      description: JWT session token for authenticated users

````