Update CRM Item: crm.item.update
Scope:
crmWho can execute the method: any user with "edit" access permission for CRM entity items
This method updates an item of a specific type in the CRM object by assigning new values from the fields parameter.
When updating an item, a standard series of checks, modifications, and automatic actions are performed:
- access permissions are verified
- required fields are checked for completion if the item's stage has changed within the same direction
- dependent required fields are checked for completion if the item's stage has changed within the same direction
- the correctness of field entries is verified
- default values are assigned to fields
- if it turns out that no field values have been changed before saving, the save is not performed
- automation rules are triggered after saving
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
entityTypeId* |
Identifier of the system or user-defined type whose item we want to change |
|
id* |
Identifier of the item we want to change. Can be obtained using the |
|
fields* |
Object in the format
where
Each type of CRM entity has its own set of fields. This means that the set of fields for changing a Lead does not have to match the set of fields for changing a Contact or SPA. The list of available fields for each type of entity is described below. An incorrect field in Note Only those fields that need to be changed should be passed in |
|
useOriginalUfNames |
Parameter to control the format of custom field names in the request and response.
Default — |
Parameter fields
Required parameters are marked with *
CRM object identifier entityTypeId: 1
|
Name |
Description |
|
title |
Item title |
|
honorific |
String identifier for the lead's honorific (e.g., The list of available honorifics can be obtained using |
|
name |
First name |
|
secondName |
Middle name |
|
lastName |
Last name |
|
birthdate |
Date of birth |
|
companyTitle |
Company name |
|
sourceId |
String identifier for the source. For example, The list of available sources can be obtained using |
|
sourceDescription |
Additional information about the source |
|
stageId |
String identifier for the item's stage. For example, The list of available stages can be obtained using |
|
statusDescription |
Additional information about the stage |
|
post |
Position |
|
currencyId |
Identifier of the item's currency |
|
isManualOpportunity |
Opportunity calculation mode. Possible values:
|
|
opportunity |
Amount |
|
opened |
Is the item available to everyone? Possible values:
|
|
comments |
Comment |
|
assignedById |
Identifier of the person responsible for the item |
|
companyId |
Identifier of the company linked to the item. The list of companies can be obtained using the |
|
contactId |
Identifier of the contact linked to the item. The list of contacts can be obtained using the |
|
contactIds |
List of identifiers of contacts linked to the item. The list of contacts can be obtained using the |
|
originatorId |
External source |
|
originId |
Identifier of the item in the external source |
|
webformId |
Identifier of the CRM Form |
|
observers |
Array of user identifiers who will be observers in the item |
|
utmSource |
Advertising system. For example: Google Ads, Bing Ads, etc. |
|
utmMedium |
Traffic type. Possible values:
|
|
utmCampaign |
Identifier of the advertising campaign |
|
utmContent |
Content of the campaign. For example, for contextual ads |
|
utmTerm |
Search condition of the campaign. For example, keywords for contextual advertising |
|
ufCrm... |
Custom field. Read about custom fields in the section Custom Fields in CRM Values of multiple fields are passed as an array. To upload a file, the value of the custom field must be an array where the first element is the file name and the second is the content of the file encoded in base64. |
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
|
fm |
Array of multifields. More about multifields can be read in the section crm_multifield Structure of a multifield:
Example:
Default — |
CRM object identifier entityTypeId: 2
|
Name |
Description |
|
title |
Item title |
|
typeId |
String identifier for the entity type. For example, for a deal: The list of available entity types can be obtained using |
|
categoryId |
Identifier of the direction (funnel) of the deal |
|
stageId |
String identifier for the item's stage. For example, The list of available stages can be obtained using
|
|
isRecurring |
Is the deal recurring? Possible values:
|
|
probability |
Probability % |
|
currencyId |
Identifier of the item's currency |
|
isManualOpportunity |
Opportunity calculation mode. Possible values:
|
|
opportunity |
Amount |
|
taxValue |
Tax amount |
|
companyId |
Identifier of the company linked to the item. The list of companies can be obtained using the |
|
contactId |
Identifier of the contact linked to the item. The list of contacts can be obtained using the |
|
contactIds |
List of identifiers of contacts linked to the item. The list of contacts can be obtained using the |
|
quoteId |
Identifier of the estimate that will be linked to the deal |
|
begindate |
Start date of the item |
|
closedate |
End date of the item |
|
opened |
Is the item available to everyone? Possible values:
|
|
comments |
Comment |
|
assignedById |
Identifier of the person responsible for the item |
|
sourceId |
String identifier for the source. For example, The list of available sources can be obtained using |
|
sourceDescription |
Additional information about the source |
|
leadId |
Identifier of the lead based on which the item is created |
|
additionalInfo |
Additional information |
|
originatorId |
External source |
|
originId |
Identifier of the item in the external source |
|
observers |
Array of user identifiers who will be observers in the item |
|
locationId |
Identifier of the location. Service field |
|
utmSource |
Advertising system. Google Ads, Bing Ads, etc. |
|
utmMedium |
Traffic type. Possible values:
|
|
utmCampaign |
Identifier of the advertising campaign |
|
utmContent |
Content of the campaign. For example, for contextual ads |
|
utmTerm |
Search condition of the campaign. For example, keywords for contextual advertising |
|
ufCrm... |
Custom field. See the section Custom Fields in CRM
|
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
CRM object identifier entityTypeId: 3
|
Name |
Description |
|
honorific |
String identifier for the contact's honorific. For example, The list of available honorifics can be obtained using |
|
name |
First name |
|
secondName |
Middle name |
|
lastName |
Last name |
|
photo |
Photo |
|
birthdate |
Date of birth |
|
typeId |
String identifier for the entity type. For example, for a deal: The list of available entity types can be obtained using |
|
sourceId |
String identifier for the source. For example, The list of available sources can be obtained using |
|
sourceDescription |
Additional information about the source |
|
post |
Position |
|
comments |
Comment |
|
opened |
Is the item available to everyone? Possible values:
|
|
export |
Is the contact participating in the export? |
|
assignedById |
Identifier of the person responsible for the item |
|
companyId |
Identifier of the company linked to the item. The list of companies can be obtained using the |
|
companyIds |
Array of identifiers of companies that will be linked to the item |
|
leadId |
Identifier of the lead based on which the item is created |
|
originatorId |
External source |
|
originId |
Identifier of the item in the external source |
|
originVersion |
Version of the original |
|
observers |
Array of user identifiers who will be observers in the item |
|
utmSource |
Advertising system. Google Ads, Bing Ads, etc. |
|
utmMedium |
Traffic type. Possible values:
|
|
utmCampaign |
Identifier of the advertising campaign |
|
utmContent |
Content of the campaign. For example, for contextual ads |
|
utmTerm |
Search condition of the campaign. For example, keywords for contextual advertising |
|
ufCrm... |
Custom field. See the section Custom Fields in CRM
|
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
|
fm |
Array of multifields. More about multifields can be read in the section crm_multifield Structure of a multifield:
Example:
Default — |
CRM object identifier entityTypeId: 4
|
Name |
Description |
|
title |
Item title |
|
typeId |
String identifier for the entity type. For example, for a deal: The list of available entity types can be obtained using |
|
logo |
Logo |
|
bankingDetails |
Banking details |
|
industry |
String identifier for the industry type. For example, The list of available industry types can be obtained using the |
|
employees |
String identifier for the number of employees. The value is taken from the available list, for example, The list of available employee counts can be obtained using the |
|
currencyId |
Identifier of the item's currency |
|
revenue |
Annual revenue |
|
opened |
Is the item available to everyone? Possible values:
|
|
comments |
Comment |
|
isMyCompany |
Is the company my company? |
|
assignedById |
Identifier of the person responsible for the item |
|
contactIds |
List of identifiers of contacts linked to the item. The list of contacts can be obtained using the |
|
leadId |
Identifier of the lead based on which the item is created. |
|
originatorId |
External source |
|
originId |
Identifier of the item in the external source |
|
originVersion |
Version of the original |
|
observers |
Array of user identifiers who will be observers in the item |
|
utmSource |
Advertising system. Google Ads, Bing Ads, etc. |
|
utmMedium |
Traffic type. Possible values:
|
|
utmCampaign |
Identifier of the advertising campaign |
|
utmContent |
Content of the campaign. For example, for contextual ads |
|
utmTerm |
Search condition of the campaign. For example, keywords for contextual advertising |
|
ufCrm... |
Custom field. See the section Custom Fields in CRM
|
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
|
fm |
Array of multifields. More about multifields can be read in the section crm_multifield Structure of a multifield:
Example:
Default — |
CRM object identifier entityTypeId: 7
|
Name |
Description |
|
title |
Item title |
|
assignedById |
Identifier of the person responsible for the item |
|
opened |
Is the item available to everyone? Possible values:
|
|
content |
Content |
|
terms |
Terms |
|
comments |
Comment |
|
dealId |
Identifier of the linked deal |
|
leadId |
Identifier of the lead based on which the item is created |
|
storageTypeId |
Identifier of the storage type. Possible values:
|
|
storageElementIds |
Array of files |
|
webformId |
Identifier of the CRM Form |
|
companyId |
Identifier of the company linked to the item. The list of companies can be obtained using the |
|
contactId |
Identifier of the contact linked to the item. The list of contacts can be obtained using the |
|
contactIds |
List of identifiers of contacts linked to the item. The list of contacts can be obtained using the |
|
locationId |
Identifier of the location. Service field |
|
currencyId |
Identifier of the item's currency |
|
isManualOpportunity |
Opportunity calculation mode.
|
|
opportunity |
Amount |
|
taxValue |
Tax amount |
|
stageId |
String identifier for the item's stage. For example, The list of available stages can be obtained using |
|
begindate |
Start date of the item |
|
closedate |
End date of the item |
|
actualDate |
Valid until |
|
mycompanyId |
Identifier of my company |
|
utmSource |
Advertising system. Google Ads, Bing Ads, etc. |
|
utmMedium |
Traffic type.
|
|
utmCampaign |
Identifier of the advertising campaign |
|
utmContent |
Content of the campaign. For example, for contextual ads |
|
utmTerm |
Search condition of the campaign. For example, keywords for contextual advertising |
|
ufCrm... |
Custom field. See the section Custom Fields in CRM.
|
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
CRM object identifier entityTypeId: 31
|
Name |
Description |
|
title |
Item title |
|
xmlId |
External code |
|
assignedById |
Identifier of the person responsible for the item |
|
opened |
Is the item available to everyone? Possible values:
|
|
webformId |
Identifier of the CRM Form |
|
begindate |
Start date of the item |
|
closedate |
End date of the item |
|
companyId |
Identifier of the company linked to the item. The list of companies can be obtained using the |
|
contactId |
Identifier of the contact linked to the item. The list of contacts can be obtained using the |
|
contactIds |
List of identifiers of contacts linked to the item. The list of contacts can be obtained using the |
|
observers |
Array of user identifiers who will be observers in the item |
|
stageId |
String identifier for the item's stage. For example, The list of available stages can be obtained using |
|
sourceId |
String identifier for the source. For example, The list of available sources can be obtained using |
|
sourceDescription |
Additional information about the source |
|
currencyId |
Identifier of the item's currency |
|
isManualOpportunity |
Opportunity calculation mode. Possible values:
|
|
opportunity |
Amount |
|
taxValue |
Tax amount |
|
mycompanyId |
Identifier of my company |
|
comments |
Comment |
|
locationId |
Identifier of the location. Service field |
|
ufCrm... |
Custom field. See the section Custom Fields in CRM.
|
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
CRM object identifier entityTypeId: can be obtained using the crm.type.list method or created using the crm.type.add method.
|
Name |
Description |
|
title |
Item title |
|
xmlId |
External code |
|
assignedById |
Identifier of the person responsible for the item |
|
opened |
Is the item available to everyone?
|
|
webformId |
Identifier of the CRM Form |
|
begindate |
Start date of the item. Available only when the |
|
closedate |
End date of the item. Available only when the |
|
companyId |
Identifier of the company linked to the item. The list of companies can be obtained using the Available only when the |
|
contactId |
Identifier of the contact linked to the item. The list of contacts can be obtained using the Available only when the |
|
contactIds |
List of identifiers of contacts linked to the item. The list of contacts can be obtained using the Available only when the |
|
observers |
Array of user identifiers who will be observers in the item. Available only when the |
|
categoryId |
Identifier of the funnel of the SPA item. If the identifier is not specified, the SPA will be moved to the main funnel. The list of available funnels can be obtained using the |
|
stageId |
String identifier for the item's stage. For example, The list of available stages can be obtained using
More about funnels (directions). Available only when the |
|
sourceId |
String identifier for the source. (for example, The list of available sources can be obtained using Available only when the |
|
sourceDescription |
Additional information about the source. Available only when the |
|
currencyId |
Identifier of the item's currency. Available only when the |
|
isManualOpportunity |
Opportunity calculation mode. Possible values:
Available only when the |
|
opportunity |
Amount. Available only when the |
|
taxValue |
Tax amount. Available only when the |
|
mycompanyId |
Identifier of my company. Available only when the |
|
ufCrm... |
Custom field. See the section Custom Fields in CRM.
|
|
parentId... |
Parent field. An element of another type of CRM object linked to this item. Each such field has the code |
SPA Settings
More about managing SPA settings can be read in Smart Processes: Overview of Methods
How to Update a Custom Field of Type File
-
Upload a new file instead of the old one (non-multiple field)
To replace a file in a non-multiple field, simply upload the new file. The old one will be automatically deleted.
{ "fields": { "ufCrm1617027453943": [ "myfile.pdf", "...base64_encoded_file_content..." ] } } -
Remove the value of the custom field of type file
To do this, simply pass an empty string (
'') instead of the value. -
Leave the value of the non-multiple field of type file unchanged
The simplest option is not to add a key with this field in
fields.But if you need to pass it and not change it, then the value should be passed as a list where the key
idwill be the file identifier.{ "fields": { "ufCrm1617027453943": { "id": 433 } } }Warning
If a value different from the current one is passed in
id, the field value will be reset and the file will be deleted. -
Working with a multiple field of type file
The value of a multiple field is an array. Each element of the array is subject to the same rules as for non-multiple values.
How to Partially Overwrite Values of a Multiple Field of Type File
For example, the current values in the multiple field of type file are
[12, 255, 44].You need to keep files
12and44, and upload a new one instead of255.The request should look as follows:
{ "fields": { "ufCrm1617027453943": [ { "id": 12 }, { "id": 44 }, [ "myNewFile.pdf", "...base64_encoded_file_content..." ] ] } }
Code Examples
Update a deal with id = 351
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"entityTypeId":2,"id":351,"fields":{"title":"REST Deal #1","stageId":"C9:UC_NYL06U","assignedById":6,"observers":[1,2,3],"opened":"N","typeId":"SERVICE","opportunity":10000,"currencyId":"USD","additionalInfo":"Updating deal via REST","isManualOpportunity":"N","utmSource":"google","ufCrm_1721244707107":200.05,"parentId1220":2}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.item.update
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"entityTypeId":2,"id":351,"fields":{"title":"REST Deal #1","stageId":"C9:UC_NYL06U","assignedById":6,"observers":[1,2,3],"opened":"N","typeId":"SERVICE","opportunity":10000,"currencyId":"USD","additionalInfo":"Updating deal via REST","isManualOpportunity":"N","utmSource":"google","ufCrm_1721244707107":200.05,"parentId1220":2},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.item.update
BX24.callMethod(
'crm.item.update',
{
entityTypeId: 2,
id: 351,
fields: {
title: "REST Deal #1",
stageId: "C9:UC_NYL06U",
assignedById: 6,
observers: [1, 2, 3],
opened: "N",
typeId: "SERVICE",
opportunity: 10000,
currencyId: "USD",
additionalInfo: "Updating deal via REST",
isManualOpportunity: "N",
utmSource: "google",
ufCrm_1721244707107: 200.05,
parentId1220: 2,
},
},
(result) => {
if (result.error())
{
console.error(result.error());
return;
}
console.info(result.data());
},
);
require_once('crest.php');
$result = CRest::call(
'crm.item.update',
[
'entityTypeId' => 2,
'id' => 351,
'fields' => [
'title' => "REST Deal #1",
'stageId' => "C9:UC_NYL06U",
'assignedById' => 6,
'observers' => [1, 2, 3],
'opened' => "N",
'typeId' => "SERVICE",
'opportunity' => 10000,
'currencyId' => "USD",
'additionalInfo' => "Updating deal via REST",
'isManualOpportunity' => "N",
'utmSource' => "google",
'ufCrm_1721244707107' => 200.05,
'parentId1220' => 2,
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
try {
$entityTypeId = 1; // Set your entity type ID
$id = 123; // Set the ID of the item to update
$fields = [
'TITLE' => 'Updated Title',
'DATE_MODIFIED' => (new DateTime())->format(DateTime::ATOM), // Example DateTime field
// Add other fields as necessary
];
$itemService = $serviceBuilder->getCRMScope()->item();
$updateResult = $itemService->update($entityTypeId, $id, $fields);
if ($updateResult->isSuccess()) {
print("Item updated successfully: " . json_encode($updateResult));
} else {
print("Failed to update item.");
}
} catch (Throwable $e) {
print("An error occurred: " . $e->getMessage());
}
Response Handling
HTTP Status: 200
{
"result": {
"item": {
"id": 351,
"createdTime": "2024-07-23T19:10:26+02:00",
"dateCreateShort": null,
"updatedTime": "2024-07-23T18:19:21+02:00",
"dateModifyShort": null,
"createdBy": 1,
"updatedBy": 1,
"assignedById": 6,
"opened": "N",
"leadId": null,
"companyId": 0,
"contactId": 0,
"quoteId": null,
"title": "REST Deal #1",
"productId": null,
"categoryId": 9,
"stageId": "C9:UC_NYL06U",
"stageSemanticId": "P",
"isNew": "N",
"isRecurring": "N",
"isReturnCustomer": "N",
"isRepeatedApproach": "N",
"closed": "N",
"typeId": "SERVICE",
"opportunity": 10000,
"isManualOpportunity": "N",
"taxValue": 0,
"currencyId": "USD",
"probability": null,
"comments": "",
"begindate": "2024-07-23T02:00:00+02:00",
"begindateShort": null,
"closedate": "2024-07-31T02:00:00+02:00",
"closedateShort": null,
"eventDate": null,
"eventDateShort": null,
"eventId": null,
"eventDescription": null,
"locationId": null,
"webformId": 0,
"sourceId": "",
"sourceDescription": "",
"originatorId": null,
"originId": null,
"additionalInfo": "Updating deal via REST",
"searchContent": "351 Deal #351 10200.00 US Dollar No Invented Invented Sale Title2134234233 23.07.2024 31.07.2024",
"orderStage": null,
"movedBy": 1,
"movedTime": "2024-07-23T18:19:21+02:00",
"lastActivityBy": 1,
"lastActivityTime": "2024-07-23T18:10:26+02:00",
"isWork": null,
"isWon": null,
"isLose": null,
"receivedAmount": null,
"lostAmount": null,
"hasProducts": null,
"ufCrm_1721244707107": 200.05,
"parentId1220": 2,
"utmSource": "google",
"utmMedium": null,
"utmCampaign": null,
"utmContent": null,
"utmTerm": null,
"observers": [
1,
2,
3
],
"contactIds": [],
"entityTypeId": 2
}
},
"time": {
"start": 1721751560.824475,
"finish": 1721751564.481578,
"duration": 3.6571030616760254,
"processing": 3.1893951892852783,
"date_start": "2024-07-23T18:19:20+02:00",
"date_finish": "2024-07-23T18:19:24+02:00",
"operating": 3.1893470287323
}
}
Returned Values
|
Name |
Description |
|
result |
Root element of the response, contains a single key |
|
item |
Information about the updated item, field descriptions |
|
time |
Information about the execution time of the request |
By default, custom field names are passed and returned in camelCase, for example, ufCrm2_1639669411830.
When passing the parameter useOriginalUfNames with the value Y, custom fields will be returned with their original names, for example, UF_CRM_2_1639669411830.
Error Handling
HTTP Status: 400, 403
{
"error": "NOT_FOUND",
"error_description": "SPA not found"
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Status |
Code |
Description |
Value |
|
|
|
Action is allowed only for intranet users |
User is not an intranet user |
|
|
|
SPA not found |
Occurs when an invalid |
|
|
|
Access denied |
User does not have permission to modify items of type |
|
|
|
Invalid value for field " |
Incorrect value passed for field |
|
|
|
Expected iterable value for multiple field, but got |
One of the multiple fields received a value of type |
|
|
|
Insufficient rights to change the stage |
If a user attempts to change the stage of an item without sufficient rights |
|
|
|
You cannot change the item due to your plan's restrictions |
Plan restrictions do not allow changing SPA items |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not allowed to be called using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The methods must be called using the HTTPS protocol |
|
|
|
The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support |
|
|
|
The REST API is available only on commercial plans |
|
|
|
The user whose access token or webhook was used to call the method lacks permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the account administrator has allowed access to this application only for specific users |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Create a new CRM entity crm.item.add
- Get Item by Id crm.item.get
- Get a list of crm.item.list elements
- Delete CRM Item - crm.item.delete
- Get Fields of CRM Item `crm.item.fields`
- CRM Object Fields