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

# Add User to Workspace

> Add an existing user to the workspace or send an invitation if the user doesn't exist.

## Authentication & Scope

Requires the `workspace-users-write` ability.

## Request

```http theme={null}
POST /workspaces/1/users/add HTTP/1.1
Host: api.raydocs.com
Authorization: Bearer <token>
Content-Type: application/json

{
  "email": "newuser@example.com",
  "role": "user"
}
```

### Path Parameters

| Parameter     | Type    | Required | Description      |
| ------------- | ------- | -------- | ---------------- |
| `workspaceId` | integer | Yes      | The workspace ID |

### Body Parameters

| Parameter | Type   | Required | Description                                    |
| --------- | ------ | -------- | ---------------------------------------------- |
| `email`   | string | Yes      | Email address of the user to add               |
| `role`    | string | Yes      | Role to assign: `admin`, `user`, or `readonly` |

## Response

`200 OK` – User added or invitation sent.

```json theme={null}
{
  "message": "User added successfully"
}
```

Or if the user doesn't exist:

```json theme={null}
{
  "message": "Invitation sent",
  "invite_id": 123
}
```

`422 Unprocessable Entity` – User is already a member or validation error.


## OpenAPI

````yaml post /workspaces/{workspaceId}/users/add
openapi: 3.0.1
info:
  title: Raydocs API
  description: REST API for document extraction with AI-powered data parsing
  version: 1.0.0
servers:
  - url: https://api.raydocs.com
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: Create and manage workspaces.
  - name: Workspace Users
    description: Manage users within a workspace.
  - name: Extraction Templates
    description: Define extraction schemas and settings.
  - name: Extraction Sessions
    description: Manage extraction jobs and documents.
  - name: Batch Operations
    description: Bulk operations on sessions.
  - name: Documents
    description: Upload and manage source documents.
  - name: Workflows
    description: Discover workflow runs and read their public outputs.
  - name: Results
    description: Access extraction results.
paths:
  /workspaces/{workspaceId}/users/add:
    post:
      tags:
        - Workspace Users
      summary: Add Workspace User
      description: >-
        Add a user to workspace by email. Sends invite if user doesn't exist.
        Requires `workspace-users-write`.
      operationId: addWorkspaceUser
      parameters:
        - name: workspaceId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - role
              properties:
                email:
                  type: string
                  format: email
                role:
                  type: string
                  enum:
                    - admin
                    - user
                    - readonly
      responses:
        '200':
          description: User added or invited
        '403':
          description: Forbidden
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Personal Access Token created from the Raydocs dashboard.

        Include in the Authorization header: `Bearer <your_token>`

        See [API Keys](/api-reference/api-keys) for token creation and
        management.

````