Create a new deal crm.deal.add
Scope:
crmWho can execute the method: any user with the "add" access permission for deals
Method Development Stopped
The method crm.deal.add continues to function, but there is a more relevant alternative crm.item.add.
The method crm.deal.add creates a new deal.
Method Parameters
|
Name |
Description |
|
fields |
Object format:
where:
The list of available fields is described below |
|
params |
Object containing an additional set of parameters (detailed description) |
Parameter fields
|
Name |
Description |
|
TITLE |
Deal title. By default, it is generated using the template |
|
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 By default — the first available deal type |
|
CATEGORY_ID |
Identifier of the funnel. Must be greater than or equal to 0. The list of available funnels can be obtained using the method crm.category.list by passing By default — the identifier of the default funnel |
|
STAGE_ID |
Stage of the deal. The list of available stages can be obtained using the method crm.status.list with the filter:
By default — the first available stage relative to the funnel |
|
IS_RECURRING |
Is the deal a template for a recurring deal? Possible values:
By default |
|
IS_RETURN_CUSTOMER |
Is the deal a repeat? Possible values:
By default |
|
IS_REPEATED_APPROACH |
Is the deal a repeated approach? Possible values:
By default |
|
PROBABILITY |
Probability, % |
|
CURRENCY_ID |
Currency. The list of available currencies can be obtained using the method crm.currency.list |
|
OPPORTUNITY |
Amount. By default |
|
IS_MANUAL_OPPORTUNITY |
Is manual calculation of the amount enabled? Possible values:
By default |
|
TAX_VALUE |
Tax amount. By default |
|
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 list of contacts can be obtained using the method crm.item.list by passing |
|
BEGINDATE |
Start date. By default — the date of deal creation |
|
CLOSEDATE |
Completion date. By default — the date of deal creation plus 7 days |
|
OPENED |
Is the deal available to everyone? Possible values:
By default |
|
CLOSED |
Is the deal closed? Possible values:
By default |
|
COMMENTS |
Comment. Supports bb-codes |
|
ASSIGNED_BY_ID |
Responsible person. By default — the user calling this method |
|
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 By default — the first available source type |
|
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 term of the campaign. For example, keywords for contextual advertising |
|
TRACE |
Information for Sales Intelligence — read more in the article How to Transfer Information to Sales Intelligence |
|
UF_CRM_... |
Custom fields. For example, Depending on the portal settings, deals may have a set of custom fields of specific types. You can add a custom field to a deal using the method crm.deal.userfield.add |
|
PARENT_ID_... |
Relationship fields. If there are SPAs related to deals on the portal, there is a field for each such SPA that stores the relationship between this SPA and the deal. The field itself stores the identifier of the element of that SPA. For example, the field |
Parameter params
|
Name |
Description |
|
REGISTER_SONET_EVENT |
Should the event of adding a deal be registered in the live feed? Possible values:
By default |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"FIELDS":{"TITLE":"New Deal #1","TYPE_ID":"COMPLEX","CATEGORY_ID":0,"STAGE_ID":"PREPARATION","IS_RECURRING":"N","IS_RETURN_CUSTOMER":"Y","IS_REPEATED_APPROACH":"Y","PROBABILITY":99,"CURRENCY_ID":"EUR","OPPORTUNITY":1000000,"IS_MANUAL_OPPORTUNITY":"Y","TAX_VALUE":0.10,"COMPANY_ID":9,"CONTACT_IDS":[84,83],"BEGINDATE":"'"$(date --iso-8601=seconds)"'","CLOSEDATE":"'"$(date --iso-8601=seconds --date='+10 days')"'", "OPENED":"Y","CLOSED":"N","COMMENTS":"Example comment","SOURCE_ID":"CALLBACK","SOURCE_DESCRIPTION":"Additional information about the source","ADDITIONAL_INFO":"Additional information","UTM_SOURCE":"google","UTM_MEDIUM":"CPC","PARENT_ID_1220":22,"UF_CRM_1721244482250":"Hello world!"},"PARAMS":{"REGISTER_SONET_EVENT":"N"}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.deal.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"FIELDS":{"TITLE":"New Deal #1","TYPE_ID":"COMPLEX","CATEGORY_ID":0,"STAGE_ID":"PREPARATION","IS_RECURRING":"N","IS_RETURN_CUSTOMER":"Y","IS_REPEATED_APPROACH":"Y","PROBABILITY":99,"CURRENCY_ID":"EUR","OPPORTUNITY":1000000,"IS_MANUAL_OPPORTUNITY":"Y","TAX_VALUE":0.10,"COMPANY_ID":9,"CONTACT_IDS":[84,83],"BEGINDATE":"'"$(date --iso-8601=seconds)"'","CLOSEDATE":"'"$(date --iso-8601=seconds --date='+10 days')"'", "OPENED":"Y","CLOSED":"N","COMMENTS":"Example comment","SOURCE_ID":"CALLBACK","SOURCE_DESCRIPTION":"Additional information about the source","ADDITIONAL_INFO":"Additional information","UTM_SOURCE":"google","UTM_MEDIUM":"CPC","PARENT_ID_1220":22,"UF_CRM_1721244482250":"Hello world!"},"PARAMS":{"REGISTER_SONET_EVENT":"N"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.deal.add
try
{
const day = 60 * 60 * 24 * 1000;
const now = new Date();
const after10Days = new Date(now.getTime() + 10 * day);
const response = await $b24.callMethod(
'crm.deal.add',
{
fields: {
TITLE: "New Deal #1",
TYPE_ID: "COMPLEX",
CATEGORY_ID: 0,
STAGE_ID: "PREPARATION",
IS_RECURRING: "N",
IS_RETURN_CUSTOMER: "Y",
IS_REPEATED_APPROACH: "Y",
PROBABILITY: 99,
CURRENCY_ID: "EUR",
OPPORTUNITY: 1000000,
IS_MANUAL_OPPORTUNITY: "Y",
TAX_VALUE: 0.10,
COMPANY_ID: 9,
CONTACT_IDS: [84, 83],
BEGINDATE: now.toISOString(),
CLOSEDATE: after10Days.toISOString(),
OPENED: "Y",
CLOSED: "N",
COMMENTS: "[B]Example comment[/B]",
SOURCE_ID: "CALLBACK",
SOURCE_DESCRIPTION: "Additional information about the source",
ADDITIONAL_INFO: "Additional information",
UTM_SOURCE: "google",
UTM_MEDIUM: "CPC",
PARENT_ID_1220: 22,
UF_CRM_1721244482250: "Hello world!",
},
params: {
REGISTER_SONET_EVENT: "N",
},
}
);
const result = response.getData().result;
result.error()
? console.error(result.error())
: console.info(result)
;
}
catch( error )
{
console.error('Error:', error);
}
try {
$fields = [
'TITLE' => 'New Deal',
'TYPE_ID' => 'GIG',
'CATEGORY_ID' => '1',
'STAGE_ID' => 'C1:NEW',
'CURRENCY_ID' => 'USD',
'OPPORTUNITY' => '10000',
'BEGINDATE' => (new DateTime())->format(DateTime::ATOM),
'CLOSEDATE' => (new DateTime('+1 month'))->format(DateTime::ATOM),
'COMMENTS' => 'This is a test deal.',
];
$params = [
'REGISTER_SONET_EVENT' => 'Y',
];
$result = $serviceBuilder
->getCRMScope()
->deal()
->add($fields, $params);
print($result->getId());
} catch (Throwable $e) {
print('Error: ' . $e->getMessage());
}
const day = 60 * 60 * 24 * 1000;
const now = new Date();
const after10Days = new Date(now.getTime() + 10 * day);
BX24.callMethod(
'crm.deal.add',
{
fields: {
TITLE: "New Deal #1",
TYPE_ID: "COMPLEX",
CATEGORY_ID: 0,
STAGE_ID: "PREPARATION",
IS_RECURRING: "N",
IS_RETURN_CUSTOMER: "Y",
IS_REPEATED_APPROACH: "Y",
PROBABILITY: 99,
CURRENCY_ID: "EUR",
OPPORTUNITY: 1000000,
IS_MANUAL_OPPORTUNITY: "Y",
TAX_VALUE: 0.10,
COMPANY_ID: 9,
CONTACT_IDS: [84, 83],
BEGINDATE: now.toISOString(),
CLOSEDATE: after10Days.toISOString(),
OPENED: "Y",
CLOSED: "N",
COMMENTS: "[B]Example comment[/B]",
SOURCE_ID: "CALLBACK",
SOURCE_DESCRIPTION: "Additional information about the source",
ADDITIONAL_INFO: "Additional information",
UTM_SOURCE: "google",
UTM_MEDIUM: "CPC",
PARENT_ID_1220: 22,
UF_CRM_1721244482250: "Hello world!",
},
params: {
REGISTER_SONET_EVENT: "N",
},
},
(result) => {
result.error()
? console.error(result.error())
: console.info(result.data())
;
},
);
require_once('crest.php');
$result = CRest::call(
'crm.deal.add',
[
'FIELDS' => [
'TITLE' => 'New Deal #1',
'TYPE_ID' => 'COMPLEX',
'CATEGORY_ID' => 0,
'STAGE_ID' => 'PREPARATION',
'IS_RECURRING' => 'N',
'IS_RETURN_CUSTOMER' => 'Y',
'IS_REPEATED_APPROACH' => 'Y',
'PROBABILITY' => 99,
'CURRENCY_ID' => 'EUR',
'OPPORTUNITY' => 1000000,
'IS_MANUAL_OPPORTUNITY' => 'Y',
'TAX_VALUE' => 0.10,
'COMPANY_ID' => 9,
'CONTACT_IDS' => [84, 83],
'BEGINDATE' => (new DateTime())->format(DateTime::ATOM),
'CLOSEDATE' => (new DateTime('+10 days'))->format(DateTime::ATOM),
'OPENED' => 'Y',
'CLOSED' => 'N',
'COMMENTS' => 'Example comment',
'SOURCE_ID' => 'CALLBACK',
'SOURCE_DESCRIPTION' => 'Additional information about the source',
'ADDITIONAL_INFO' => 'Additional information',
'UTM_SOURCE' => 'google',
'UTM_MEDIUM' => 'CPC',
'PARENT_ID_1220' => 22,
'UF_CRM_1721244482250' => 'Hello world!',
],
'PARAMS' => [
'REGISTER_SONET_EVENT' => 'N',
],
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": 394,
"time": {
"start": 1725013197.635808,
"finish": 1725013198.580873,
"duration": 0.9450650215148926,
"processing": 0.6822988986968994,
"date_start": "2024-08-30T12:19:57+02:00",
"date_finish": "2024-08-30T12:19:58+02:00",
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response, contains the identifier of the created deal |
|
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 parameter |
|
|
|
The user does not have permission to "add" 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
- Update Deal crm.deal.update
- 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
- Add a deal and company with requisites