# Notification group conditions

A notification group condition is a module and event pair by which the group selects notifications. This page covers adding a condition to a group and removing a single condition.

## Add a condition to a group

`POST /v1/notifications/groups/:groupId/conditions`

Adds one more module and event pair to a group the user created. After that the group also selects notifications of this event.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `groupId` (path) | number | yes | Group identifier — the `tag` value of a group with `isEditable: true` from [`GET /v1/notifications/groups`](./groups.md), passed as a number. The system groups `confirm`, `mention` and `admin` have no numeric identifier |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `module` | string | yes | Module identifier, 1 to 255 characters. The list of modules is the `data[].id` field in [`GET /v1/notifications/settings`](./settings.md); the module of a specific notification is the `notifyModule` field in the [notification feed](./list.md) |
| `event` | string | yes | Identifier of an event of this module, 1 to 255 characters. The module's events are the `data[].notices[].id` field in [`GET /v1/notifications/settings`](./settings.md); the event of a specific notification is the `notifyEvent` field in the [notification feed](./list.md) |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "module": "calendar", "event": "invite" }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "module": "calendar", "event": "invite" }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ module: 'calendar', event: 'invite' }),
})

const { data } = await res.json()
console.log('Condition ID:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ module: 'calendar', event: 'invite' }),
})

const { data } = await res.json()
console.log('Condition ID:', data.id)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | Condition identifier. You do not need it to remove the condition — a condition is identified by its `module` and `event` pair |

## Response example

HTTP 200:

```json
{
  "success": true,
  "data": {
    "id": 31
  }
}
```

## Error response example

422 — the group already has this condition:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Mysql query error: (1062) Duplicate entry '12-calendar-invite' for key 'b_im_notify_group_condition.UX_IM_NOTIFY_GROUP_CONDITION_GROUP_ID_MODULE_EVENT'",
    "b24Code": "400"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `groupId` is not a positive integer, including a system group tag such as `mention` |
| 400 | `INVALID_PARAMS` | `module` or `event` was not passed, is not a string, is an empty string or is longer than 255 characters. The field name is in `message` |
| 400 | `INVALID_PARAMS` | A body field not listed in the table above or a query parameter was passed, or the body is not a JSON object |
| 404 | `ENTITY_NOT_FOUND` | The group does not exist — it was deleted or belongs to another user. The portal code `GROUP_NOT_FOUND` is in the `error.b24Code` field. On a portal whose interface language is neither Russian nor English, the same refusal arrives as `422 BITRIX_ERROR` — rely on `error.b24Code` |
| 422 | `BITRIX_ERROR` | The group already has this condition. `error.b24Code` holds `400`, and `message` holds the Bitrix24 database error text about a duplicate entry. A duplicate has no separate code — check the group's contents with [`GET /v1/notifications/groups`](./groups.md) before adding |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the addition for another reason; the portal code is in the `error.b24Code` field |
| 403 | `SCOPE_DENIED` | The key lacks the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

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

## Remove a condition from a group

`DELETE /v1/notifications/groups/:groupId/conditions`

Removes a single condition from a group the user created — the module and event pair named in the query parameters.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `groupId` (path) | number | yes | Group identifier — the `tag` value of a group with `isEditable: true` from [`GET /v1/notifications/groups`](./groups.md), passed as a number |
| `module` (query) | string | yes | Condition module, 1 to 255 characters, passed once. The group's modules are the keys of `conditions.moduleConditions` in [`GET /v1/notifications/groups`](./groups.md) |
| `event` (query) | string | yes | Condition event, 1 to 255 characters, passed once. The module's events are the `events` array under its key in `conditions.moduleConditions` |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions?module=calendar&event=invite" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions?module=calendar&event=invite" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const params = new URLSearchParams({ module: 'calendar', event: 'invite' })
const res = await fetch(`https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions?${params}`, {
  method: 'DELETE',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { success } = await res.json()
console.log('Condition removed:', success)
```

### JavaScript — OAuth application

```javascript
const params = new URLSearchParams({ module: 'calendar', event: 'invite' })
const res = await fetch(`https://vibecode.bitrix24.com/v1/notifications/groups/12/conditions?${params}`, {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success } = await res.json()
console.log('Condition removed:', success)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | boolean | Always `true`. The success indicator is the HTTP code `200`, not the value |

## Response example

HTTP 200:

```json
{
  "success": true,
  "data": true
}
```

## Error response example

400 — `event` was not passed:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Query parameter `event` must be a non-empty string of up to 255 characters."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `groupId` is not a positive integer, including a system group tag such as `mention` |
| 400 | `INVALID_PARAMS` | `module` or `event` was not passed, is empty, is longer than 255 characters or was passed twice. The parameter name is in `message` |
| 400 | `INVALID_PARAMS` | Another query parameter or a body field was passed, or the body is not a JSON object. The name is in `message` |
| 404 | `ENTITY_NOT_FOUND` | The group does not exist — it was deleted or belongs to another user. The portal code `GROUP_NOT_FOUND` is in the `error.b24Code` field. On a portal whose interface language is neither Russian nor English, the same refusal arrives as `422 BITRIX_ERROR` — rely on `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the removal; the portal code is in the `error.b24Code` field |
| 403 | `SCOPE_DENIED` | The key lacks the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

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

## Known specifics

- Removing the last condition also deletes the group itself: it disappears from [`GET /v1/notifications/groups`](./groups.md). To replace the only condition of a group, add the new one first, then remove the old one.
- A request with a module and event pair the group does not have also returns `200` with `data: true`. Such a response does not confirm that the condition was in the group — check against the group list.

## See also

- [Notification groups](./groups.md)
- [Notification settings](./settings.md)
- [Notification feed](./list.md)
- [Notifications](/docs/notifications)
- [Errors](/docs/errors)
