
## Add a line

`POST /v1/telephony-lines`

Registers a new external application line in the Bitrix24 account. After creation the line is available in [`GET /v1/telephony-lines`](./list.md) and can be used as `fromLine` in outbound calls. Fields are passed flat at the JSON root — without a `fields` wrapper.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `number` | string | yes | Unique line identifier in the Bitrix24 account |
| `name` | string | no | Display name of the line |
| `crmAutoCreate` | boolean | no | Auto-create a CRM entity on an outbound call through the line: `true` — create, `false` — do not. Defaults to `true` |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/telephony-lines" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "number": "sip-line-1",
    "name": "Main line",
    "crmAutoCreate": false
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/telephony-lines" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "number": "sip-line-1",
    "name": "Main line",
    "crmAutoCreate": false
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/telephony-lines', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    number: 'sip-line-1',
    name: 'Main line',
    crmAutoCreate: false,
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/telephony-lines', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    number: 'sip-line-1',
    name: 'Main line',
    crmAutoCreate: false,
  }),
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | Internal record identifier in Bitrix24. Not used for subsequent operations — update and delete are keyed by `number` |

## Response example

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

## Error response example

422 — the `number` field was not provided:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "NUMBER should not be empty"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error — text in `error.message`. Causes: `number` not provided, duplicate identifier |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not provided |
| 401 | `INVALID_API_KEY` | Invalid API key |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |
| 401 | `KEY_INACTIVE` | The API key is inactive or revoked |
| 403 | `SCOPE_DENIED` | The key lacks the `telephony` scope |
| 429 | `RATE_LIMITED` | Request rate limit exceeded |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable |

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

## Known specifics

**`serverName` is declared in `GET /v1/telephony-lines/fields` but does not work.** The field is accepted on creation (response `201`), but it is not stored, not returned on read, and not updated (a `PATCH` with `serverName` alone responds `422 "There are no fields to update"`). Do not use it — the value you pass is lost.

**The `crmAutoCreate` field is a camelCase boolean.** Pass `true`/`false`; if omitted, the line is created with the default value `true`. Previously only the UPPER_SNAKE name `CRM_AUTO_CREATE` was accepted as a `"Y"`/`"N"` string and `crmAutoCreate` was silently dropped — since 07.2026 the canonical form is a camelCase boolean (the raw UPPER variant is still accepted on write for compatibility).

**`data.id` is an internal identifier, not used for other operations.** Updating and deleting a line are done by the `number` from the request body, not by `data.id` from the response. Save the `number` you passed — it is exactly what goes into the `PATCH /v1/telephony-lines/:number` and `DELETE /v1/telephony-lines/:number` URLs. Values with `+`, spaces, or `/` are allowed — when substituted into the URL they must be encoded: `+12025550123` → `%2B12025550123`.

## See also

- [List application lines](./list.md) — `GET /v1/telephony-lines`
- [Update a line](./update.md) — `PATCH /v1/telephony-lines/:number`
- [Delete a line](./delete.md) — `DELETE /v1/telephony-lines/:number`
- [Outbound calls](/docs/telephony/outbound) — using `number` as `fromLine`
