## Invite members

`POST /v1/workgroups/:groupId/invitations`

Sends users an invitation to join a workgroup. They become members only after they accept the invitation in Bitrix24 themselves.

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `groupId` (path) | number | yes | Workgroup ID — a positive integer. List: [`GET /v1/workgroups`](/docs/entities/workgroups/list) |

## Request fields (body)

| Field | Type | Required | Description |
|-------|------|:--------:|-------------|
| `userIds` | number[] | yes | Non-empty array of IDs of the users to invite — positive integers. List: [`GET /v1/users`](/docs/entities/users/list) |
| `message` | string | no | Invitation text the user will see |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/workgroups/157/invitations" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"userIds": [93], "message": "Join the project group"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/workgroups/157/invitations" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"userIds": [93], "message": "Join the project group"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/workgroups/157/invitations', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ userIds: [93], message: 'Join the project group' }),
})

const body = await res.json()
if (!body.success && body.error.code === 'BITRIX_ERROR') {
  if (Array.isArray(body.error.processedUserIds)) {
    // Invitations to processedUserIds have already been sent — do not resend them
    console.log('Invited:', body.error.processedUserIds)
    console.log('Not invited:', body.error.skippedUserIds)
  } else {
    // The other 422: Bitrix24 refused the call, so the response has no arrays
    console.log('Bitrix24 refused:', body.error.message)
  }
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/workgroups/157/invitations', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ userIds: [93], message: 'Join the project group' }),
})

const body = await res.json()
```

## Response fields

| Field | Type | Description |
|-------|------|-------------|
| `success` | boolean | `true` when invitations have been sent to all requested users |
| `data.groupId` | number | Workgroup ID |
| `data.processedUserIds` | number[] | IDs of the users who were sent an invitation. Duplicates in `userIds` collapse into one |
| `data.skippedUserIds` | number[] | Always an empty array in a successful response. If not everyone could be invited, the response is `422 BITRIX_ERROR` and both arrays move into `error`. That is the only response that carries them: the other `422 BITRIX_ERROR` — a refusal from Bitrix24 itself — carries only its own message in `error`, with no `processedUserIds` and no `skippedUserIds` |

## Response example

```json
{
  "success": true,
  "data": {
    "groupId": 157,
    "processedUserIds": [93],
    "skippedUserIds": []
  }
}
```

## Error response example

422 — the user has already been invited and has not responded yet:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Bitrix24 did not change every requested user: existing membership or role, owner, scrum master, missing user or permissions may prevent the action. Do not blindly retry invitations.",
    "processedUserIds": [],
    "skippedUserIds": [93]
  }
}
```

## Errors

| HTTP | Code | Description |
|------|------|-------------|
| 400 | `INVALID_PARAMS` | `groupId` is not a positive integer, for example `15.7` |
| 400 | `INVALID_PARAMS` | `message` is sent but is not a string |
| 400 | `MISSING_REQUIRED_FIELDS` | `userIds` is missing, empty or contains something other than positive integers |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is not sent |
| 401 | `INVALID_API_KEY` | The key is not recognized — no such key exists on the platform |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key lacks the `sonet_group` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key works in read-only mode |
| 403 | `BITRIX_ACCESS_DENIED` | The user the key acts on behalf of has no permission to invite users to this group |
| 404 | `ENTITY_NOT_FOUND` | The group does not exist or is not visible to the user the key acts on behalf of |
| 422 | `BITRIX_ERROR` | Not every user was invited. `error.processedUserIds` and `error.skippedUserIds` list who received an invitation and who did not. Reasons for skipping: the user has already been invited and has not responded, or the user is already a group member |
| 422 | `BITRIX_ERROR` | Bitrix24 refused the call and returned its own reason in `error.message`. This response carries no `error.processedUserIds` and no `error.skippedUserIds`: it does not say who did get an invitation — do not blindly repeat the call |
| 429 | `RATE_LIMITED` | Request limit exceeded. Retry after the delay in the `Retry-After` header |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a response the endpoint cannot parse |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 accepted the call but did not respond in time. The response includes a `Retry-After` header. The invitation may already have been sent — do not blindly repeat the call |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **An invitation reaches a real person.** Every successful call sends the user a real invitation. A retry after `422` or `503` does not cancel invitations already sent: the users in `error.processedUserIds` have received theirs.
- **An invited user is not visible in the group membership.** Until the invitation is accepted, [`GET /v1/workgroups/:groupId/users`](/docs/entities/workgroups/users) does not show this user, and [`POST /v1/workgroups/:groupId/users`](./add.md) skips them with `422`.
- **An invitation is cancelled by removal.** [`DELETE /v1/workgroups/:groupId/users`](./remove.md) with the invited user's ID withdraws the invitation. After that, the user can be added to the group right away with [`POST /v1/workgroups/:groupId/users`](./add.md).

## See also

- [Add members](./add.md)
- [Remove members](./remove.md)
- [List workgroup members](/docs/entities/workgroups/users)
- [Workgroup members](/docs/workgroups/members)
