Activate the crm.automation.trigger
Scope:
crmWho can execute the method: a user with access permission to modify the target object
target
Bitrix24 allows users to create a special custom trigger "Track Incoming Webhook." The user is provided with a ready-made URL of the form
https://mydomain.bitrix24.com/rest/1/{{PASSWORD}}/crm.automation.trigger/?target=DEAL_{{ID}}&code=nwly5
A call to this URL from an external source will trigger the automation and transition the CRM entity to another stage in the Sales Funnel.
As you can see from the format of this URL, a local incoming webhook is effectively created within Bitrix24, which calls the crm.automation.trigger method, specifying a specific CRM object and the unique symbolic code of the trigger that was created by Bitrix24 itself (in the example above, this is nwly5).
You can use the method not only via the incoming webhook but also in the context of local and mass-market applications. However, to invoke your own triggers created by your application, you need to use the method crm.automation.trigger.execute
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
target* |
Target object for automation, specified in the form of |
|
code |
Unique symbolic code of the trigger configured in Automation for a specific status/stage of the document. The |
Note
In rare cases, multiple triggers may be detected for the specified target object. This happens if:
codeis not passed in the request and there are old triggers on the account that do not have acode- a
codeis passed that turns out to be the same for multiple triggers
In this case, the first trigger that sets an earlier status for the CRM object will be activated.
It is also worth noting that triggers have "Conditions" and the option "Allow transitioning to the previous status," which affect whether the trigger will work or not.
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"target":"DEAL_57","code":"c5u4m"}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.automation.trigger
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"target":"DEAL_57","code":"c5u4m","auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.automation.trigger
try
{
const response = await $b24.callMethod(
"crm.automation.trigger",
{
target: 'DEAL_57',
code: 'c5u4m',
}
);
const result = response.getData().result;
console.dir(result);
}
catch(error)
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'crm.automation.trigger',
[
'target' => 'DEAL_57',
'code' => 'c5u4m',
]
);
$result = $response
->getResponseData()
->getResult();
if ($result->error()) {
error_log($result->error());
} else {
echo 'Success: ' . print_r($result->data(), true);
}
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error triggering automation: ' . $e->getMessage();
}
BX24.callMethod(
"crm.automation.trigger",
{
target: 'DEAL_57',
code: 'c5u4m',
},
function(result)
{
if(result.error())
console.error(result.error());
else
console.dir(result.data());
}
);
require_once('crest.php');
$result = CRest::call(
'crm.automation.trigger',
[
'target' => 'DEAL_57',
'code' => 'c5u4m'
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP Status: 200
{
"result": true,
"time": {
"start":1718809827.810153,
"finish":1718809828.541046,
"duration":0.7308928966522217,
"processing":0.09834408760070801,
"date_start":"2024-06-19T15:10:27+00:00",
"date_finish":"2024-06-19T15:10:28+00:00"
}
}
Returned Data
|
Name |
Description |
|
result |
Result of trigger activation |
|
time |
Information about the request execution time |
Error Handling
HTTP Status: 400
{
"error":"",
"error_description":"Target is not set."
}
|
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 |
Error Message |
Description |
|
Empty string |
Target is not set. |
The required parameter |
|
Empty string |
Incorrect target format. |
The |
|
Empty string |
Target is not found. |
An incorrect |
|
|
Access denied! There are no permissions to update the entity. |
The user did not pass the permission check to trigger the automation. |
|
Empty string |
Access denied. |
The user did not pass the preliminary permission check for CRM access |
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 |