Register a new event handler event.bind
Who can execute the method: any user
The method event.bind registers a new event handler.
The method works only in the context of application authorization. It can operate both under a user with portal administration rights and under a regular user. The method for a user without administrator rights is available with limitations:
- Offline events are not available; attempting to set them will raise an exception.
- Events are set on behalf of the current user (see the description of the
auth_typeparameter). Explicitly specifying anauth_typedifferent from theIDof the current user will also raise an exception.
Note
Since requests will come from Bitrix servers, any URL must be accessible for GET/POST requests from the outside.
The interface for this method is BX24.callBind.
Note
When deleting and updating the application, its actions will be removed. Therefore, in the installer of each version, they need to be set from scratch.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
event* |
Event name |
|
handler* |
Link to the event handler |
|
auth_type |
User ID under which the event handler is authorized. By default, the authorization of the user whose actions triggered the event will be used |
|
event_type |
Values: |
|
auth_connector |
Source key. This parameter is intended for offline events. It allows excluding false event triggers |
|
options |
Additional settings for the registered event, if any |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"event": "ONCRMLEADADD",
"handler": "https://www.my-domain.com/handler/",
"auth": "**put_access_token_here**"
}' \
https://**put_your_bitrix24_address**/rest/event.bind
BX24.callBind(
'ONCRMLEADADD',
'https://www.my-domain.com/handler/',
15,
(result) => console.log(result)
);
require_once('crest.php');
$result = CRest::call(
'event.bind',
[
'event' => 'ONCRMLEADADD',
'handler' => 'https://www.my-domain.com/handler/',
'auth_type' => 15
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": true,
"time": {
"start": 1721296536.908506,
"finish": 1721296537.007365,
"duration": 0.09885907173156738,
"processing": 0.03251290321350098,
"date_start": "2024-07-18T11:55:36+02:00",
"date_finish": "2024-07-18T11:55:37+02:00",
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Success of execution |
|
time |
Information about the execution time of the request |
Error Handling
HTTP status: 400
{
"error":"ERROR_EVENT_NOT_FOUND",
"error_description":"Event 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
|
Code |
Error Message |
Description |
|
|
Event not found |
Incorrect event specified |
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
- Get a list of available events
- Get a List of Registered Event Handlers event.get
- Unbind Registered Event Handler event.unbind
- Security in Handlers
- Features, Advantages, and Disadvantages of Offline Events
- Get a list of offline events event.offline.list
- Get a List of Offline Events with `event.offline.get`
- Clear records in the offline event queue event.offline.clear
- Register Errors for Processing Offline Events event.offline.error
- Event of Queue Change onOfflineEvent
- How to Create an Open Channel Connector for Chat on the Site