## Replace participants

`PUT /v1/call-lists/:id`

Replaces all call list participants with the ones in the request and removes participants missing from it.

The body is passed in full, as when creating a list, flat at the JSON root, without a `fields` wrapper.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Call list ID. List: [`GET /v1/call-lists`](/docs/entities/call-lists/list) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `entityType` | string | yes | Participant type: `CONTACT` or `COMPANY`. Must match the list's `entityType` from [`GET /v1/call-lists/:id`](/docs/entities/call-lists/get) |
| `entities` | number[] | yes | The new full list of participants, a nonempty array of positive integers. Contacts: [`GET /v1/contacts`](/docs/entities/contacts/list), companies: [`GET /v1/companies`](/docs/entities/companies/list) |
| `webformId` | number | no | CRM form linked to the list. Form list: [`GET /v1/crm-forms`](/docs/entities/crm-forms/list). If the field is omitted, the link is reset to `null`. To keep the form, pass the current `webformId` from [`GET /v1/call-lists/:id`](/docs/entities/call-lists/get) |

Field values and relations to other entities — [call list key fields](/docs/entities/call-lists#key-fields).

## Examples

### curl — personal key

```bash
curl -X PUT "https://vibecode.bitrix24.com/v1/call-lists/17" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "entityType": "CONTACT",
    "entities": [9, 19]
  }'
```

### curl — OAuth application

```bash
curl -X PUT "https://vibecode.bitrix24.com/v1/call-lists/17" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "entityType": "CONTACT",
    "entities": [9, 19]
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/call-lists/17', {
  method: 'PUT',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    entityType: 'CONTACT',
    entities: [9, 19],
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/call-lists/17', {
  method: 'PUT',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    entityType: 'CONTACT',
    entities: [9, 19],
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` on successful replacement |
| `data` | object | Replacement result |
| `data.id` | number | List ID, matches `id` from the path |
| `data.skipped` | number[] | IDs from `entities` that are missing from the participant list read back after the replacement on behalf of the key owner. An empty array means the list contains all passed participants |

The new participants with their statuses — [`GET /v1/call-lists/:id/items`](/docs/entities/call-lists/items).

## Response example

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

## Error response example

400 — the participant type does not match the list type:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "entityType must match the existing call list"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `entityType` differs from the list type, for example `COMPANY` for a contact list. The message contains `entityType must match the existing call list` |
| 400 | `MISSING_REQUIRED_FIELDS` | The body has no `entityType` or `entities`, or the body is not a JSON object. The message contains `entityType and entities are required` |
| 400 | `UNKNOWN_FIELD` | The body has a field other than `entityType`, `entities` and `webformId`. The message contains `Supported write fields` |
| 400 | `INVALID_PARAMS` | `entityType` has any other value, for example `LEAD`. The message contains `entityType must be CONTACT or COMPANY` |
| 400 | `INVALID_PARAMS` | `entities` is empty, not an array, or contains a value that is not a positive integer. The message contains `entities must be a nonempty list` |
| 400 | `INVALID_PARAMS` | `webformId` is not a positive integer. The message contains `webformId must be a positive safe integer` |
| 400 | `INVALID_PARAMS` | `id` in the path is not a positive integer. The message contains `id must be a positive safe integer` |
| 404 | `ENTITY_NOT_FOUND` | No list with this `id` exists, or it is not accessible to the key owner. The message contains `Call list not found or inaccessible` |
| 422 | `BITRIX_ERROR` | No participant with this ID exists in CRM. The response has `b24Code: "ENTITIES_ERROR"`. The list participants do not change. The message contains `Incorrect entities id` |
| 422 | `BITRIX_ERROR` | No CRM form with this `webformId` exists. The response has `b24Code: "WEBFORM_ERROR"`. The list participants do not change. The message contains `Incorrect webform id` |
| 422 | `BITRIX_ERROR` | Bitrix24 did not confirm the replacement. Read [list participants](/docs/entities/call-lists/items) to see the current participants. The message contains `Bitrix24 did not confirm the call-list replacement` |
| 422 | `BITRIX_ERROR` | The verification read after replacement found a participant that is not in `entities` or has a different type. The replacement has already been applied. The message contains `participants outside the requested call-list composition` |
| 502 | `BITRIX_RESPONSE_INVALID` | The Bitrix24 response did not match the expected list or participant structure. If the failure happened during the verification read, the replacement has already been applied |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only, so replacement is unavailable |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is not passed |
| 401 | `TOKEN_MISSING` | The key has no configured Bitrix24 tokens |

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

## Known specifics

**A single participant is added or removed through the full participant list.** Read the current participants through [list participants](/docs/entities/call-lists/items) across all pages, change the array, and pass it to `entities` in full.

## See also

- [Create a call list](/docs/entities/call-lists/create)
- [Get a call list](/docs/entities/call-lists/get)
- [List participants](/docs/entities/call-lists/items)
- [Participant statuses](/docs/entities/call-lists/statuses)
- [List call lists](/docs/entities/call-lists/list)
- Related entities: [Contacts](/docs/entities/contacts), [Companies](/docs/entities/companies), [CRM forms](/docs/entities/crm-forms)
