Update Contact crm.contact.update

Choose a tool for developing with an AI agent:

  • use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
  • use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation

Scope: crm

Who can execute the method: any user with "edit" access permission for contacts

DEPRECATED

Development of this method has been discontinued. Please use crm.item.update.

The method crm.contact.update updates an existing contact.

It is recommended to pass the complete set of address fields when updating an address.

Method Parameters

Required parameters are marked with *

Name
type

Description

id*
integer

The identifier of the contact to be changed.

The identifier can be obtained using the methods crm.contact.list or crm.contact.add

fields*
object

An object in the following format:

{
            field_1: value_1,
            field_2: value_2,
            ...,
            field_n: value_n,
        }
        

where:

  • field_n — field name
  • value_n — new field value

The list of available fields is described below.

An incorrect field in fields will be ignored.

Only the fields that need to be changed should be passed in fields

params
object

An object containing a set of additional parameters.

The structure and possible values are described below

Parameter fields

Name
type

Description

HONORIFIC
crm_status

Salutation.

The list of available salutation types can be obtained using crm.status.list with the filter { ENTITY_ID: "HONORIFIC" }

NAME
string

First name

SECOND_NAME
string

Middle name

LAST_NAME
string

Last name

PHOTO
file

Photograph

BIRTHDATE
date

Date of birth

TYPE_ID
crm_status

Contact type.
The list of available contact types can be obtained using crm.status.list with the filter { ENTITY_ID: "CONTACT_TYPE" }

SOURCE_ID
crm_status

Source
The list of available source types can be obtained using crm.status.list with the filter { ENTITY_ID: "SOURCE" }

SOURCE_DESCRIPTION
string

Additional information about the source

POST
string

Position

COMMENTS
string

Comment. Supports BB codes

OPENED
boolean

Is it available to everyone? Possible values:

  • Y — yes
  • N — no

EXPORT
boolean

Is the contact participating in the export? Possible values:

  • Y — yes
  • N — no

ASSIGNED_BY_ID
user

Identifier of the user responsible for the item

COMPANY_ID
crm_company

Identifier of the main company for the contact.

The list of companies can be obtained using the method crm.item.list with entityTypeId = 4

COMPANY_IDS
crm_company[]

Array of identifiers of companies to which the contact is linked.

The list of companies can be obtained using the method crm.item.list with entityTypeId = 4

UTM_SOURCE
string

Advertising system (Google Ads, Microsoft Advertising, etc.)

UTM_MEDIUM
string

Traffic type. Possible values:

  • CPC — ads
  • CPM — banners

UTM_CAMPAIGN
string

Advertising campaign designation

UTM_CONTENT
string

Content of the campaign. For example, for contextual ads

UTM_TERM
string

Search condition of the campaign. For example, keywords for contextual advertising

PHONE
crm_multifield[]

Phone

EMAIL
crm_multifield[]

E-mail

WEB
crm_multifield[]

Website

IM
crm_multifield[]

Messenger

LINK
crm_multifield[]

Links. System field

UF_...

Custom fields. For example, UF_CRM_25534736.

Depending on the portal settings, contacts may have a set of custom fields of defined types.

To change file fields, it is recommended to use the method crm.item.update.

A custom field can be added to a contact using the method crm.contact.userfield.add

PARENT_ID_...

Relationship fields.

If there are smart processes related to contacts on the portal, there is a field for each such smart process that stores the relationship between that smart process and the contact. The field itself stores the identifier of the element of that smart process.

For example, the field PARENT_ID_153 — relationship with the smart process entityTypeId=153. It stores the identifier of the element of that smart process related to the current contact

Fields for external data sources

If the contact was created by an external system, then:

  • the field ORIGINATOR_ID stores the string identifier of that system
  • the field ORIGIN_ID stores the string identifier of the contact in that external system
  • the field ORIGIN_VERSION stores the version of the contact data in that external system

Name
type

Description

ORIGINATOR_ID
string

Identifier of the external system that is the source of data about this contact

ORIGIN_ID
string

Version of the contact data in the external system. Used to protect data from accidental overwriting by the external system.

If the data was imported and not changed in the external system, then such data can be edited in CRM without fear that the next export will lead to overwriting of the data

ORIGIN_VERSION
string

Version of the original

Deprecated fields

Address fields in the contact are deprecated and are only used in compatibility mode. To work with the address, use requisites.

Name
type

Description

ADDRESS
string

Address

ADDRESS_2
string

Second line of the address

ADDRESS_CITY
string

City

ADDRESS_POSTAL_CODE
string

Postal code

ADDRESS_REGION
string

Region

ADDRESS_PROVINCE
string

Province

ADDRESS_COUNTRY
string

Country

ADDRESS_COUNTRY_CODE
string

Country code

ADDRESS_LOC_ADDR_ID
integer

Location address identifier

Parameter params

Name
type

Description

REGISTER_SONET_EVENT
boolean

Should the update event of the contact be registered in the activity stream? Possible values:

  • Y — yes
  • N — no

Default is N

REGISTER_HISTORY_EVENT
boolean

Should the update of the contact be registered in the history? Possible values:

  • Y — yes
  • N — no

Default is Y

Code Examples

How to Use Examples in Documentation

Update contact with id = 43

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":43,"FIELDS":{"NAME":"John","BIRTHDATE":"11.11.1999","TYPE_ID":"RECOMMENDATION","SOURCE_ID":"WEB","POST":"Network Administrator","COMMENTS":"New comment","OPENED":"N","EXPORT":"Y","ASSIGNED_BY_ID":1,"COMPANY_ID":12,"COMPANY_IDS":[13,15],"UF_CRM_1720697698689":"Example of a new value for a custom field of type \"String\"","PARENT_ID_1224":14},"PARAMS":{"REGISTER_SONET_EVENT":"N","REGISTER_HISTORY_EVENT":"N"}}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.contact.update
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":43,"FIELDS":{"NAME":"John","BIRTHDATE":"11.11.1999","TYPE_ID":"RECOMMENDATION","SOURCE_ID":"WEB","POST":"Network Administrator","COMMENTS":"New comment","OPENED":"N","EXPORT":"Y","ASSIGNED_BY_ID":1,"COMPANY_ID":12,"COMPANY_IDS":[13,15],"UF_CRM_1720697698689":"Example of a new value for a custom field of type \"String\"","PARENT_ID_1224":14},"PARAMS":{"REGISTER_SONET_EVENT":"N","REGISTER_HISTORY_EVENT":"N"},"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.contact.update
        
// This snippet is an ES module: top-level await requires type="module" or a bundler.
        // $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
        import { Text } from '@bitrix24/b24jssdk'
        import type { B24Frame } from '@bitrix24/b24jssdk'
        
        declare const $b24: B24Frame
        
        try {
          const response = await $b24.actions.v2.call.make<boolean>({
            method: 'crm.contact.update',
            params: {
              id: 43,
              fields: {
                NAME: 'Sergey',
                BIRTHDATE: '11.11.1999',
                TYPE_ID: 'RECOMMENDATION',
                SOURCE_ID: 'WEB',
                POST: 'Computer network administrator',
                COMMENTS: 'New comment',
                OPENED: 'N',
                EXPORT: 'Y',
                ASSIGNED_BY_ID: 1,
                COMPANY_ID: 12,
                COMPANY_IDS: [13, 15],
                UF_CRM_1720697698689: 'Example new value of a custom field of type "String"',
                PARENT_ID_1224: 14,
              },
              params: {
                REGISTER_SONET_EVENT: 'N',
                REGISTER_HISTORY_EVENT: 'N',
              },
            },
            requestId: Text.getUuidRfc4122()
          })
        
          // The payload is available only on a successful response
          if (!response.isSuccess) {
            console.error(response.getErrorMessages().join('; '))
          } else {
            const result = response.getData()!.result
            console.info('Contact updated:', result)
          }
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
        
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
        <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
        <script>
          async function updateContact() {
            try {
              // Initialize the SDK inside a Bitrix24 frame
              const $b24 = await B24Js.initializeB24Frame()
        
              const response = await $b24.actions.v2.call.make({
                method: 'crm.contact.update',
                params: {
                  id: 43,
                  fields: {
                    NAME: 'Sergey',
                    BIRTHDATE: '11.11.1999',
                    TYPE_ID: 'RECOMMENDATION',
                    SOURCE_ID: 'WEB',
                    POST: 'Computer network administrator',
                    COMMENTS: 'New comment',
                    OPENED: 'N',
                    EXPORT: 'Y',
                    ASSIGNED_BY_ID: 1,
                    COMPANY_ID: 12,
                    COMPANY_IDS: [13, 15],
                    UF_CRM_1720697698689: 'Example new value of a custom field of type "String"',
                    PARENT_ID_1224: 14,
                  },
                  params: {
                    REGISTER_SONET_EVENT: 'N',
                    REGISTER_HISTORY_EVENT: 'N',
                  },
                },
                requestId: B24Js.Text.getUuidRfc4122()
              })
        
              // The payload is available only on a successful response
              if (!response.isSuccess) {
                console.error(response.getErrorMessages().join('; '))
                return
              }
        
              const result = response.getData().result
              console.info('Contact updated:', result)
            } catch (error) {
              // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
              console.error(error)
            }
          }
        
          document.addEventListener('DOMContentLoaded', updateContact)
        </script>
        
try {
            $contactId = 123; // Example contact ID
            $fields = [
                'NAME' => 'John',
                'LAST_NAME' => 'Doe',
                'BIRTHDATE' => (new DateTime('1990-01-01'))->format(DateTime::ATOM),
                'PHONE' => '123456789',
                'EMAIL' => 'john.doe@example.com',
                'ADDRESS' => '123 Main St',
                'ADDRESS_CITY' => 'Anytown',
                'ADDRESS_COUNTRY' => 'USA',
            ];
            $params = [
                'REGISTER_SONET_EVENT' => 'Y',
            ];
            $result = $serviceBuilder
                ->getCRMScope()
                ->contact()
                ->update($contactId, $fields, $params);
            if ($result->isSuccess()) {
                print($result->getCoreResponse()->getResponseData()->getResult()[0]);
            } else {
                print('Update failed.');
            }
        } catch (Throwable $e) {
            print('Error: ' . $e->getMessage());
        }
        
BX24.callMethod(
            'crm.contact.update',
            {
                id: 43,
                fields: {
                    NAME: "John",
                    BIRTHDATE: '11.11.1999',
                    TYPE_ID: "RECOMMENDATION",
                    SOURCE_ID: "WEB",
                    POST: "Network Administrator",
                    COMMENTS: "New comment",
                    OPENED: "N",
                    EXPORT: "Y",
                    ASSIGNED_BY_ID: 1,
                    COMPANY_ID: 12,
                    COMPANY_IDS: [13, 15],
                    UF_CRM_1720697698689: "Example of a new value for a custom field of type \"String\"",
                    PARENT_ID_1224: 14,
                },
                params: {
                    REGISTER_SONET_EVENT: "N",
                    REGISTER_HISTORY_EVENT: "N",
                },
            },
            (result) => {
                result.error()
                    ? console.error(result.error())
                    : console.info(result.data())
                ;
            },
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.contact.update',
            [
                'ID' => 43,
                'FIELDS' => [
                    'NAME' => 'John',
                    'BIRTHDATE' => '11.11.1999',
                    'TYPE_ID' => 'RECOMMENDATION',
                    'SOURCE_ID' => 'WEB',
                    'POST' => 'Network Administrator',
                    'COMMENTS' => 'New comment',
                    'OPENED' => 'N',
                    'EXPORT' => 'Y',
                    'ASSIGNED_BY_ID' => 1,
                    'COMPANY_ID' => 12,
                    'COMPANY_IDS' => [13, 15],
                    'UF_CRM_1720697698689' => 'Example of a new value for a custom field of type "String"',
                    'PARENT_ID_1224' => 14,
                ],
                'PARAMS' => [
                    'REGISTER_SONET_EVENT' => 'N',
                    'REGISTER_HISTORY_EVENT' => 'N',
                ]
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        
// client and ctx are already created — see the Go SDK section
        res, err := client.Core().Call(ctx, "crm.contact.update", b24.Params{
        	"id": 43,
        	"fields": b24.Params{
        		"NAME":                 "John",
        		"BIRTHDATE":            "11.11.1999",
        		"TYPE_ID":              "RECOMMENDATION",
        		"SOURCE_ID":            "WEB",
        		"POST":                 "Network Administrator",
        		"COMMENTS":             "New comment",
        		"OPENED":               "N",
        		"EXPORT":               "Y",
        		"ASSIGNED_BY_ID":       1,
        		"COMPANY_ID":           12,
        		"COMPANY_IDS":          []int{13, 15},
        		"UF_CRM_1720697698689": "Example of a new value for a custom field of type \"String\"",
        		"PARENT_ID_1224":       14,
        	},
        	"params": b24.Params{
        		"REGISTER_SONET_EVENT":   "N",
        		"REGISTER_HISTORY_EVENT": "N",
        	},
        })
        if err != nil {
        	return fmt.Errorf("crm.contact.update: %w", err)
        }
        
        // The response arrives as json.RawMessage — unmarshal it
        // into a struct matching the response shape shown below on this page.
        fmt.Printf("%s\n", res.Result)
        

Working with Multiple Fields

Update a Multiple Field

To overwrite an existing value of a multiple field, pass the ID of the field you want to change and its new value/type.

Suppose there are the following values for the PHONE field:

[
            {
                "ID": "222",
                "VALUE_TYPE": "WORK",
                "VALUE": "111111",
                "TYPE_ID": "PHONE"
            },
            {
                "ID": "223",
                "VALUE_TYPE": "WORK",
                "VALUE": "222222",
                "TYPE_ID": "PHONE"
            },
            {
                "ID": "224",
                "VALUE_TYPE": "WORK",
                "VALUE": "333333",
                "TYPE_ID": "PHONE"
            }
        ]
        

To change the value of the phone with ID = 223, pass the following fields parameter:

{
            "fields": {
                "PHONE": [
                    {
                        "ID": 223,
                        "VALUE": "444444",
                        "VALUE_TYPE": "MOBILE"
                    }
                ]
            }
        }
        

Delete a Single Value from a Multiple Field

To delete one of the values from a multiple field, pass their identifiers and either the parameter DELETE = 'Y' or an empty VALUE.

Suppose there are the following values for the PHONE field:

[
            {
                "ID": "222",
                "VALUE_TYPE": "WORK",
                "VALUE": "111111",
                "TYPE_ID": "PHONE"
            },
            {
                "ID": "223",
                "VALUE_TYPE": "WORK",
                "VALUE": "222222",
                "TYPE_ID": "PHONE"
            },
            {
                "ID": "224",
                "VALUE_TYPE": "WORK",
                "VALUE": "333333",
                "TYPE_ID": "PHONE"
            },
            {
              "ID": "225",
              "VALUE_TYPE": "WORK",
              "VALUE": "44444",
              "TYPE_ID": "PHONE"
            }
        ]
        

Let’s consider ways to delete all values except the phone with ID = 225:

{
            "fields": {
                "PHONE": [
                    {
                        "ID": 222,
                        "DELETE": "Y"
                    },
                    {
                        "ID": 223,
                        "VALUE": ""
                    },
                    {
                        "ID": 224
                    }
                ]
            }
        }
        

As a result, the following will remain:

[
            {
                "ID": "225",
                "VALUE_TYPE": "WORK",
                "VALUE": "44444",
                "TYPE_ID": "PHONE"
            }
        ]
        

Add a New Value to a Multiple Field

To add a new value, simply enter it. Existing values will not be changed.

Example of adding a new value 55555:

{
            "fields": {
                "PHONE": [
                    {
                        "VALUE": "55555",
                        "VALUE_TYPE": "WORK"
                    }
                ]
            }
        }
        

Response Handling

HTTP status: 200

{
            "result": true,
            "time": {
                "start": 1723820393.459406,
                "finish": 1723820396.129949,
                "duration": 2.6705431938171387,
                "processing": 2.1193439960479736,
                "date_start": "2024-08-16T16:59:53+02:00",
                "date_finish": "2024-08-16T16:59:56+02:00"
            }
        }
        

Returned Data

Name
type

Description

result
boolean

Root element of the response, true in case of success

time
time

Information about the execution time of the request

Error Handling

HTTP status: 400

{
            "error": "",
            "error_description": "Contact is not found"
        }
        

Name
type

Description

error
string

String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only error_description shows the reason

error_description
string

Error message for the developer. Do not show it to the end user without processing

Possible Error Codes

Code

Description

Value

Empty value

Parameter 'fields' must be array

The fields parameter is not an object

Empty value

Parameter 'params' must be array

The params parameter is not an object

Empty value

Access denied

The user does not have permission to "Edit" contacts

Empty value

Disk resource exhausted

ERROR_CORE

The field Work e-mail contains an invalid address

Statuses and System Error Codes

HTTP Status: 4xx, 5xx

The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.

Status

Code
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

429

OPERATION_TIME_LIMIT
Method is blocked due to operation time limit

The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit

401

NO_AUTH_FOUND
Wrong authorization data

The request contains no authorization data: neither an access token nor a webhook code was passed

401

INVALID_REQUEST
Https required

Methods are called over the HTTPS protocol only

401

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support

401

ACCESS_DENIED
REST is available only on commercial plans

REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — REST is available only by subscription

401

INVALID_CREDENTIALS
Invalid request credentials

No active webhook with the specified user identifier and secret code was found

404

ERROR_METHOD_NOT_FOUND
Method not found!

No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope

401

insufficient_scope
The request requires higher privileges than provided by the webhook token

The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with provided by the access token

401

expired_token
The access token provided has expired

The access token has expired

401

user_access_error
The user does not have access to the application

The application is installed, but the Bitrix24 administrator has granted access to it only to specific users

403

PORTAL_DELETED
Portal was deleted

The public part of the site is closed. To open it on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site

Continue Learning