## Set the primary CRM contact

`PUT /v1/deals/:id/primary-contact`

`PUT /v1/leads/:id/primary-contact`

`PUT /v1/quotes/:id/primary-contact`

`PUT /v1/invoices/:id/primary-contact`

`PUT /v1/items/:entityTypeId/:id/primary-contact`

Select an already bound contact as primary without replacing other bindings.

> These operations require the `crm-rest-v3` flag and a Bitrix24 update after `crm 26.2200.0` with `RestV3CrudDeal` enabled. Until available, calls return `422 METHOD_NOT_YET_AVAILABLE` with `error.release`.

Requires `crm` scope and `READWRITE` access. [Resource and value formats](/docs/entities/crm-field-values).

## Parameters

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` (path) | integer | yes | — | Record ID from the corresponding list resource |
| `entityTypeId` (path) | integer | for items | — | Smart-process type from [List smart process types](/docs/entities/smart-processes/list) |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `contactId` | integer | yes | Already bound contact ID from [List contacts](/docs/entities/contacts/list) |

## Examples

### curl — personal key

```bash
curl -i -X PUT "https://vibecode.bitrix24.com/v1/deals/12/primary-contact" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contactId":34}'
```

### curl — OAuth application

```bash
curl -i -X PUT "https://vibecode.bitrix24.com/v1/deals/12/primary-contact" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"contactId":34}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/deals/12/primary-contact', {
  method: 'PUT',
  headers: { 'X-Api-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({"contactId": 34})
})
console.log(res.status === 204)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/deals/12/primary-contact', {
  method: 'PUT',
  headers: { 'X-Api-Key': 'YOUR_APP_KEY', 'Content-Type': 'application/json', 'Authorization': 'Bearer USER_SESSION_TOKEN' },
  body: JSON.stringify({"contactId": 34})
})
console.log(res.status === 204)
```

## Response fields

Success is HTTP `204 No Content` with an empty body. Check the status, do not parse JSON.

## Response example

```http
HTTP/1.1 204 No Content
```

## Error response example

400 — missing request field.

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Body must contain only contactId"
  }
}
```

## Errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | Invalid request shape or ID |
| 400 | `UNKNOWN_FILTER_FIELD` | Unknown query parameter |
| 400 | `INVALID_ENTITY_TYPE_ID` | Reserved type requires its named resource |
| 401 | `TOKEN_MISSING` | Bitrix24 credentials are missing |
| 403 | `SCOPE_DENIED` | Key lacks crm scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | Key forbids writes |
| 404 | `ENTITY_NOT_FOUND` | Record was not found |
| 422 | `METHOD_NOT_YET_AVAILABLE` | Feature unavailable; error.release identifies the update |
| 502 | `BITRIX_UNAVAILABLE` | No valid update confirmation |

Bitrix24 failures use standard V1 error handling; messages are sanitized to remove credentials. [Common errors](/docs/errors).

## See also

- [CRM field values and primary contact](/docs/entities/crm-field-values)
