# Telephony lines

Outgoing lines of the Bitrix24 account: the list of available lines and the default line for the entire account.

**Scope:** `telephony` | **Base URL:** `https://vibecode.bitrix24.com/v1` | **Authorization:** `X-Api-Key`

[Voximplant lines](/docs/telephony/lines/voximplant) returns line identifiers through `GET /v1/voximplant-lines`.

You can [get the default outgoing line](/docs/voximplant-lines/default) and [set it](/docs/voximplant-lines/default-set) for the entire Bitrix24 account. When setting the line, use an identifier from the list of available lines.

## Quick start

The current default outgoing line:

```bash
curl "https://vibecode.bitrix24.com/v1/voximplant-lines/default" \
  -H "X-Api-Key: YOUR_API_KEY"
```

The response carries the line ID in `data.lineId`. The response fields are described on the [Get default outgoing line](/docs/voximplant-lines/default) page.

## Full example

Get the list of lines, read the current default line and set another one. The script runs in Node.js 18+ from a file with the `.mjs` extension. Changing the line affects the entire Bitrix24 account.

```javascript
const BASE = 'https://vibecode.bitrix24.com/v1'
const API_KEY = 'YOUR_API_KEY'

async function call(method, path, body) {
  const headers = { 'X-Api-Key': API_KEY }
  if (body) headers['Content-Type'] = 'application/json'
  const res = await fetch(BASE + path, { method, headers, body: body && JSON.stringify(body) })
  const json = await res.json()
  if (!json.success) throw new Error(`${json.error.code}: ${json.error.message}`)
  return json.data
}

// 1. Account lines: [{ id, name }, ...]
const lines = await call('GET', '/voximplant-lines')
console.log('Lines:', lines.map(line => `${line.id} — ${line.name}`))

// 2. Current default line
const current = await call('GET', '/voximplant-lines/default')
console.log('Current default:', current.lineId)

// 3. Set the first line from the list that differs from the current one
const next = lines.find(line => line.id !== current.lineId)
if (next) {
  const saved = await call('PUT', '/voximplant-lines/default', { lineId: next.id })
  console.log('Set:', saved.lineId)
}
```

## Endpoint reference

| Method | Path | Bitrix24 method | Description |
|-------|------|---------------|----------|
| GET | [`/v1/voximplant-lines`](/docs/telephony/lines/voximplant) | voximplant.line.get | List of outgoing lines of the account |
| GET | [`/v1/voximplant-lines/default`](/docs/voximplant-lines/default) | voximplant.line.outgoing.get | Current default outgoing line |
| PUT | [`/v1/voximplant-lines/default`](/docs/voximplant-lines/default-set) | voximplant.line.outgoing.set | Set the default outgoing line |

## Error codes

| HTTP | Code | When |
|------|-----|-------|
| 400 | `MISSING_REQUIRED_FIELDS` | When changing the line, the body has no `lineId`, or `lineId` is an empty string or not a string |
| 400 | `INVALID_PARAMS` | When changing the line, `lineId` is not in the `GET /v1/voximplant-lines` list |
| 400 | `UNSUPPORTED_FILTER` | The `filter` parameter was passed to the line list request |
| 403 | `SCOPE_DENIED` | The key does not have the `telephony` scope |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request or did not confirm the line change; the reason is in `error.message` |

Other error codes for this section's methods are in the `## Errors` tables on the [Voximplant lines](/docs/telephony/lines/voximplant), [Get default outgoing line](/docs/voximplant-lines/default) and [Set default outgoing line](/docs/voximplant-lines/default-set) pages. For the full list of common API errors, see [Errors](/docs/errors).

## See also

- [SIP connections](/docs/voximplant-sip)
- [Calls](/docs/calls)
- [Telephony](/docs/telephony)
