For AI agents: markdown of this page — /docs-content-en/entities/crm-field-values/primary-contact.md documentation index — /llms.txt
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-v3flag and a Bitrix24 update aftercrm 26.2200.0withRestV3CrudDealenabled. Until available, calls return422 METHOD_NOT_YET_AVAILABLEwitherror.release.
Requires crm scope and READWRITE access. Resource and value formats.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
Parameterid (path) |
Typeinteger | Requiredyes | Default— | DescriptionRecord ID from the corresponding list resource |
ParameterentityTypeId (path) |
Typeinteger | Requiredfor items | Default— | DescriptionSmart-process type from List smart process types |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
FieldcontactId |
Typeinteger | Requiredyes | DescriptionAlready bound contact ID from List contacts |
Examples
curl — personal key
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
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
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
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/1.1 204 No Content
Error response example
400 — missing request field.
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "Body must contain only contactId"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionInvalid request shape or ID |
| HTTP400 | CodeUNKNOWN_FILTER_FIELD |
DescriptionUnknown query parameter |
| HTTP400 | CodeINVALID_ENTITY_TYPE_ID |
DescriptionReserved type requires its named resource |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionBitrix24 credentials are missing |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionKey lacks crm scope |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionKey forbids writes |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionRecord was not found |
| HTTP422 | CodeMETHOD_NOT_YET_AVAILABLE |
DescriptionFeature unavailable; error.release identifies the update |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionNo valid update confirmation |
Bitrix24 failures use standard V1 error handling; messages are sanitized to remove credentials. Common errors.