## Set default outgoing line

`PUT /v1/voximplant-lines/default`

Sets the outgoing telephony line that the Bitrix24 account uses by default and returns the value stored on the account after the write. The setting is shared across the entire account. To read the current line, use [`GET /v1/voximplant-lines/default`](/docs/voximplant-lines/default).

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

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|-------|----------|
| `lineId` | string | yes | Line ID from [`GET /v1/voximplant-lines`](/docs/telephony/lines/voximplant) |

## Examples

### curl — personal key

```bash
curl -X PUT "https://vibecode.bitrix24.com/v1/voximplant-lines/default" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"lineId": "reg151083"}'
```

### curl — OAuth application

```bash
curl -X PUT "https://vibecode.bitrix24.com/v1/voximplant-lines/default" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"lineId": "reg151083"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/voximplant-lines/default', {
  method: 'PUT',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ lineId: 'reg151083' }),
})
const { data } = await res.json()
console.log('Set:', data.lineId)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/voximplant-lines/default', {
  method: 'PUT',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ lineId: 'reg151083' }),
})
const { data } = await res.json()
console.log('Set:', data.lineId)
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` on success |
| `data` | object | Line setting |
| `data.lineId` | string \| null | ID of the default outgoing line, read from the Bitrix24 account after the write |

## Response example

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

## Error response example

400 — `lineId` is not in the account's line list:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "lineId must come from GET /v1/voximplant-lines"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `MISSING_REQUIRED_FIELDS` | The body has no `lineId`, or `lineId` is an empty string or not a string |
| 400 | `INVALID_PARAMS` | `lineId` is not in the [`GET /v1/voximplant-lines`](/docs/telephony/lines/voximplant) list. The setting does not change |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |
| 401 | `INVALID_API_KEY` | The platform does not recognize the key string: a typo, a truncated value or a deleted key |
| 401 | `TOKEN_MISSING` | The key has no access to the Bitrix24 account: a personal key has no account webhook, or an application key was sent without `Authorization: Bearer` with a session token |
| 403 | `SCOPE_DENIED` | The key does not have the `telephony` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | A read-only key attempts to change the line |
| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied access — [causes](/docs/errors/auth#bitrix_access_denied-403) |
| 403 | `B24_TARIFF_RESTRICTION` | The operation is not available on the Bitrix24 account plan |
| 422 | `BITRIX_ERROR` | Bitrix24 did not confirm the line change |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request; the reason is in `error.message` |
| 429 | `RATE_LIMITED` | Request rate exceeded |
| 429 | `QUEUE_OVERFLOW` | The account request queue is full, so the request is rejected without waiting. The `Retry-After` header suggests the delay |
| 429 | `QUEUE_TIMEOUT` | The request did not get through the account queue in time and was not sent to Bitrix24. The `Retry-After` header suggests the delay |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time |
| 503 | `user_self_deletion_pending` | The key owner is deleting their Bitrix24 user account. The `Retry-After` header equals `604800` — the length of the deletion grace period |

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

## See also

- [Get default outgoing line](/docs/voximplant-lines/default)
- [Telephony lines](/docs/voximplant-lines)
- [Voximplant lines](/docs/telephony/lines/voximplant)
- [SIP connections](/docs/voximplant-sip)
