
## Create Open Channel configuration

`POST /v1/openline-configs`

Creates a new Open Channel configuration. At least one recognised writable field is enough to create one — the remaining parameters take their default values. The full record with identifiers and all fields is available via `GET /v1/openline-configs/:id`.

## Request fields (body)

Minimum to create: at least one recognised writable field (see [Configuration fields](/docs/openlines/config/fields)).

**Field names.** Pass every field in camelCase (`name`, `active`, `queueType`, `crmCreate`, `workTimeFrom`, etc. — see [Configuration fields](/docs/openlines/config/fields)) — the canonical case, as it appears in responses and in `GET /v1/openline-configs/fields`. B24-native UPPER_SNAKE_CASE names are also accepted for backward compatibility and mapped to the right Bitrix24 name automatically. The example below uses camelCase.

**Boolean fields** (`active`, `crm`, `workTimeEnable`, `welcomeMessage`, …) accept `true` / `false` — the value is coerced to Bitrix24's expected `"Y"`/`"N"` automatically.

| Field | Type | Req. | Description |
|------|-----|-------|---------|
| `name` | string | no | Open Channel name |
| `active` | boolean | no | Whether the channel is active (`true` / `false`) |
| `queueType` | string | no | Queue distribution: `all` — to everyone at once, `evenly` — evenly, `strictly` — strictly in order |
| `queueTime` | number | no | Wait time in the queue (seconds) before transfer |
| `noAnswerTime` | number | no | Time without a response (seconds) after which the `noAnswerRule` rule triggers |
| `crm` | boolean | no | Enable CRM integration |
| `crmCreate` | string | no | Mode for creating CRM entities on a new inquiry |
| `workTimeEnable` | boolean | no | Enable the working-hours schedule |
| `workTimeFrom` | string | no | Start of the working day (for example, `"9"` or `"9.30"`) |
| `workTimeTo` | string | no | End of the working day (for example, `"18"` or `"18.30"`) |
| `workTimeTimezone` | string | no | Schedule time zone (for example, `"UTC"`) |
| `welcomeMessage` | boolean | no | Enable the welcome message |
| `welcomeMessageText` | string | no | Welcome message text |
| `languageId` | string | no | Channel language (for example, `"en"`, `"de"`) |

Full field list — [`GET /v1/openline-configs/fields`](/docs/openlines/config/fields).

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/openline-configs \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Customer support",
    "active": true,
    "queueType": "evenly",
    "workTimeEnable": true,
    "workTimeFrom": "9",
    "workTimeTo": "18"
  }'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/openline-configs \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Customer support",
    "active": true,
    "queueType": "evenly",
    "workTimeEnable": true,
    "workTimeFrom": "9",
    "workTimeTo": "18"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/openline-configs', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Customer support',
    active: true,
    queueType: 'evenly',
    workTimeEnable: true,
    workTimeFrom: '9',
    workTimeTo: '18',
  }),
})

const { success, data } = await res.json()
console.log('New configuration ID:', data)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/openline-configs', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Customer support',
    active: true,
    queueType: 'evenly',
    workTimeEnable: true,
    workTimeFrom: '9',
    workTimeTo: '18',
  }),
})

const { success, data } = await res.json()
console.log('New configuration ID:', data)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | number | Identifier of the created configuration |
| `meta.warnings` | string[] | Optional. Present when some passed fields are unrecognised — lists the keys Bitrix24 ignored |

## Response example

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

## Error response example

400 — the body has no recognised field:

```json
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "No recognised openline-configs field in the body. Unrecognised: bogusField. Provide at least one known field (e.g. lineName, queueType, active) — see GET /v1/openline-configs/fields."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `VALIDATION_ERROR` | The request body is empty — no field was passed |
| 400 | `VALIDATION_ERROR` | The body has no recognised field (all keys are unknown) — the message lists the unrecognised fields |
| 400 | `READONLY_FIELD` | A read-only field (`id`, `queue`, `dateCreate`, and others) was passed in the body |
| 401 | `TOKEN_MISSING` | The `X-Api-Key` header was not passed |
| 403 | `SCOPE_DENIED` | The API key lacks the `imopenlines` scope |

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

## Known specifics

`data` in the response is a number (the identifier of the new configuration), not a record object. To get the created configuration with all fields, make a separate request: `GET /v1/openline-configs/:id`.

**Unrecognised fields.** Bitrix24 silently ignores unknown keys of the `imopenlines.config.add` method. The wrapper checks the body against the full field schema ([Configuration fields](/docs/openlines/config/fields)) and reacts as follows:

- no field is recognised (e.g. `{ "bogusField": "x" }`) — the request is rejected with `400 VALIDATION_ERROR` before the Bitrix24 call, and the message lists the unrecognised fields.
- at least one field is recognised but some keys are unknown — the configuration is created, and the response carries `meta.warnings` with the list of ignored keys.
- a read-only field (`id`, `queue`, `dateCreate`, and others) is passed in the body — the request is rejected with `400 READONLY_FIELD`.

## See also

- [Get configuration](/docs/openlines/config/get)
- [List configurations](/docs/openlines/config/list)
- [Configuration fields](/docs/openlines/config/fields)
