Update Deal crm.deal.update
Scope:
crmWho can execute the method: any user with "edit" access permission for deals
Method Development Stopped
The method crm.deal.update continues to function, but there is a more relevant alternative crm.item.update.
The method crm.deal.update updates an existing deal.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
id* |
Identifier of the deal. The identifier can be obtained using the methods crm.deal.list or crm.deal.add |
|
fields |
Object format:
where:
The list of available fields is described below. An incorrect field in Only those fields that need to be changed should be passed in |
|
params |
Set of additional parameters (detailed description) |
Parameter fields
|
Name |
Description |
|
TITLE |
Title of the deal |
|
TYPE_ID |
String identifier of the deal type. The list of available deal types can be obtained using the method crm.status.list with the filter |
|
STAGE_ID |
Stage of the deal. The list of available stages can be obtained using the method crm.status.list with the filter:
If it is necessary to change the funnel of the deal, use the method crm.item.update, with the |
|
IS_RECURRING |
Indicates whether the deal is a recurring deal template. Possible values:
|
|
IS_RETURN_CUSTOMER |
Indicates whether the deal is a repeat deal. Possible values:
|
|
IS_REPEATED_APPROACH |
Indicates whether the deal is a repeated approach. Possible values:
|
|
PROBABILITY |
Probability, % |
|
CURRENCY_ID |
Currency. The list of available currencies can be obtained using the method crm.currency.list |
|
OPPORTUNITY |
Amount |
|
IS_MANUAL_OPPORTUNITY |
Indicates whether manual calculation mode is enabled. Possible values:
|
|
TAX_VALUE |
Tax amount |
|
COMPANY_ID |
Identifier of the company associated with the deal. The list of companies can be obtained using the method crm.item.list by passing |
|
CONTACT_ID |
Contact. Deprecated |
|
CONTACT_IDS |
List of contacts associated with the deal. The field is completely replaced. To change individual related contacts, use the methods crm.deal.contact.items.*. |
|
BEGINDATE |
Start date |
|
CLOSEDATE |
End date |
|
OPENED |
Is the deal available to everyone. Possible values:
|
|
CLOSED |
Is the deal closed. Possible values:
|
|
COMMENTS |
Comment. Supports bb-codes |
|
ASSIGNED_BY_ID |
Responsible person |
|
SOURCE_ID |
String identifier of the source type. The list of available sources can be obtained using the method crm.status.list with the filter |
|
SOURCE_DESCRIPTION |
Additional information about the source |
|
ADDITIONAL_INFO |
Additional information |
|
LOCATION_ID |
Client's location. System field |
|
ORIGINATOR_ID |
Identifier of the data source. Used only for linking to an external source |
|
ORIGIN_ID |
Identifier of the element in the data source. Used only for linking to an external source |
|
UTM_SOURCE |
Advertising system (Google-Adwords and others) |
|
UTM_MEDIUM |
Type of traffic. Possible values:
|
|
UTM_CAMPAIGN |
Designation of the advertising campaign |
|
UTM_CONTENT |
Content of the campaign. For example, for contextual ads |
|
UTM_TERM |
Search condition of the campaign. For example, keywords for contextual advertising |
|
UF_CRM_... |
Custom fields. For example, Depending on the portal settings, deals may have a set of custom fields of specific types. Values of multiple fields are passed as an array. To change file fields, it is recommended to use the method crm.item.update. You can add a custom field to a deal using the method crm.deal.userfield.add |
|
PARENT_ID_... |
Relationship fields. If there are smart processes related to deals on the portal, there is a field for each such smart process that stores the relationship between this smart process and the deal. The field itself stores the identifier of the element of that smart process. For example, the field |
Parameter params
|
Name |
Description |
|
REGISTER_SONET_EVENT |
Whether to register the deal change event in the activity stream. Possible values:
|
|
REGISTER_HISTORY_EVENT |
Whether to create a history record. Possible values:
|
Related methods and topics
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"ID":123,"FIELDS":{"TITLE":"New Deal Title!","TYPE_ID":"GOODS","STAGE_ID":"WON","IS_RECURRING":"Y","IS_RETURN_CUSTOMER":"Y","OPPORTUNITY":9999.99,"IS_MANUAL_OPPORTUNITY":"Y","ASSIGNED_BY_ID":1,"UF_CRM_1725365197310":"String","PARENT_ID_1032":1},"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.deal.update
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"ID":123,"FIELDS":{"TITLE":"New Deal Title!","TYPE_ID":"GOODS","STAGE_ID":"WON","IS_RECURRING":"Y","IS_RETURN_CUSTOMER":"Y","OPPORTUNITY":9999.99,"IS_MANUAL_OPPORTUNITY":"Y","ASSIGNED_BY_ID":1,"UF_CRM_1725365197310":"String","PARENT_ID_1032":1},"PARAMS":{"REGISTER_SONET_EVENT":"N","REGISTER_HISTORY_EVENT":"N"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.deal.update
try
{
const response = await $b24.callMethod(
'crm.deal.update',
{
id: 123,
fields: {
TITLE: "New Deal Title!",
TYPE_ID: "GOODS",
STAGE_ID: "WON",
IS_RECURRING: "Y",
IS_RETURN_CUSTOMER: "Y",
OPPORTUNITY: 9999.99,
IS_MANUAL_OPPORTUNITY: "Y",
ASSIGNED_BY_ID: 1,
UF_CRM_1725365197310: "String",
PARENT_ID_1032: 1,
},
params: {
REGISTER_SONET_EVENT: "N",
REGISTER_HISTORY_EVENT: "N",
},
}
);
const result = response.getData().result;
result.error() ? console.error(result.error()) : console.info(result);
}
catch( error )
{
console.error('Error:', error);
}
try {
$response = $b24Service
->core
->call(
'crm.deal.update',
[
'id' => 123,
'fields' => [
'TITLE' => "New Deal Title!",
'TYPE_ID' => "GOODS",
'STAGE_ID' => "WON",
'IS_RECURRING' => "Y",
'IS_RETURN_CUSTOMER' => "Y",
'OPPORTUNITY' => 9999.99,
'IS_MANUAL_OPPORTUNITY' => "Y",
'ASSIGNED_BY_ID' => 1,
'UF_CRM_1725365197310' => "String",
'PARENT_ID_1032' => 1,
],
'params' => [
'REGISTER_SONET_EVENT' => "N",
'REGISTER_HISTORY_EVENT' => "N",
],
]
);
$result = $response
->getResponseData()
->getResult();
if ($response->getError()) {
echo 'Error: ' . $response->getError();
} else {
echo 'Success: ' . print_r($result, true);
// Your logic for processing data
processData($result);
}
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error updating deal: ' . $e->getMessage();
}
BX24.callMethod(
'crm.deal.update',
{
id: 123,
fields: {
TITLE: "New Deal Title!",
TYPE_ID: "GOODS",
STAGE_ID: "WON",
IS_RECURRING: "Y",
IS_RETURN_CUSTOMER: "Y",
OPPORTUNITY: 9999.99,
IS_MANUAL_OPPORTUNITY: "Y",
ASSIGNED_BY_ID: 1,
UF_CRM_1725365197310: "String",
PARENT_ID_1032: 1,
},
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.deal.update',
[
'ID' => 123,
'FIELDS' => [
'TITLE' => 'New Deal Title!',
'TYPE_ID' => 'GOODS',
'STAGE_ID' => 'WON',
'IS_RECURRING' => 'Y',
'IS_RETURN_CUSTOMER' => 'Y',
'OPPORTUNITY' => 9999.99,
'IS_MANUAL_OPPORTUNITY' => 'Y',
'ASSIGNED_BY_ID' => 1,
'UF_CRM_1725365197310' => 'String',
'PARENT_ID_1032' => 1,
],
'PARAMS' => [
'REGISTER_SONET_EVENT' => 'N',
'REGISTER_HISTORY_EVENT' => 'N',
],
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Method Explanation
For managing deal contacts, it is not recommended to use the fields CONTACT_IDS and CONTACT_ID.
Use the methods crm.deal.contact.* for working with a single contact, and the methods crm.deal.contact.items.* for working with a group of deal contacts.
Response Handling
HTTP status: 200
{
"result": true,
"time": {
"start": 1725365418.056843,
"finish": 1725365419.671506,
"duration": 1.6146628856658936,
"processing": 1.3475170135498047,
"date_start": "2024-09-03T14:10:18+02:00",
"date_finish": "2024-09-03T14:10:19+02:00",
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response, contains |
|
time |
Information about the execution time of the request |
Error Handling
HTTP status: 400
{
"error": "",
"error_description": "Parameter 'fields' must be array."
}
|
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
|
Code |
Description |
Value |
|
|
|
The parameter |
|
|
|
The deal with the provided |
|
|
|
The parameter |
|
|
|
The parameter |
|
|
|
The user does not have permission to "edit" deals |
|
|
Disk resource exhausted |
|
|
|
Invalid value for the "Currency" field |
|
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 deal crm.deal.add
- Get Deal by Id crm.deal.get
- Get a list of deals crm.deal.list
- Delete deal crm.deal.delete
- Get Deal Fields crm.deal.fields
- Update CRM Item: crm.item.update
- How to Save the Payment Date in the Deal Field