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

# Invite a user to a workspace

> Sends a workspace invitation to the given `email` address at the specified `role`.

Creates an invitation link and sends an email; if the user is not yet registered, a signup link is included.

Returns the created invitation or `null`.



## OpenAPI

````yaml post /workspace/invite-user
openapi: 3.1.0
info:
  title: HERO API
  version: current
  description: |-
    The HERO REST API.

    See https://developers.myhero.so for the rendered docs.
servers:
  - url: https://app.myhero.so
security: []
paths:
  /workspace/invite-user:
    post:
      tags:
        - Workspaces
      summary: Invite a user to a workspace
      description: >-
        Sends a workspace invitation to the given `email` address at the
        specified `role`.


        Creates an invitation link and sends an email; if the user is not yet
        registered, a signup link is included.


        Returns the created invitation or `null`.
      operationId: inviteUserToWorkspace
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                workspaceId:
                  type: string
                  minLength: 1
                role:
                  type: string
                  enum:
                    - owner
                    - admin
                    - member
                    - editor
                    - viewer
              required:
                - email
                - workspaceId
                - role
      responses:
        '200':
          description: 200 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type:
                      - object
                      - 'null'
                    properties:
                      _id:
                        type: string
                      email:
                        type: string
                      invitedBy:
                        type: string
                      data: {}
                      status:
                        type: string
                        enum:
                          - pending
                          - accepted
                          - expired
                          - declined
                          - revoked
                      expires:
                        type: number
                      createdAt:
                        type: number
                      updatedAt:
                        type: number
                    required:
                      - _id
                      - email
                      - invitedBy
                      - status
                      - expires
                      - createdAt
                      - updatedAt
                required:
                  - data
        '400':
          description: 400 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
        '403':
          description: 403 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
        '404':
          description: 404 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: HERO personal access token

````