## Create a notification group

`POST /v1/notifications/groups`

Creates a notification group together with its first condition — a module and event pair. Further conditions are added to an existing group with the [Add a condition to a notification group](/docs/notifications/groups/conditions-create) operation.

## Request fields (body)

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

## Examples

### curl — personal key

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

### curl — OAuth application

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

### JavaScript — personal key

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

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

### JavaScript — OAuth application

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

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | Identifier of the new group. In the group list it arrives as a string in the `tag` field |

## Response example

HTTP 200:

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

## Error response example

400 — `title` was not passed:

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

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `title`, `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 |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the creation; 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).

## See also

- [List notification groups](/docs/notifications/groups/list)
- [Add a condition to a notification group](/docs/notifications/groups/conditions-create)
- [Get notification settings](/docs/notifications/settings/list)
- [Notification feed](/docs/notifications/list)
