Call the interface to remove a registered event handler BX24.callUnbind
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
BX24.callUnbind(
String event,
String handler[,
Integer|null auth_type[,
Function callback
]
]
);
The function BX24.callUnbind removes an event handler registered for the current application. The library calls the event.unbind method on behalf of the user who opened the application. The spelling BX24.callUnBind is the same call, kept for compatibility.
Only the handlers of the application the call is made from are removed, and only the handlers of online events. A handler of an offline event is removed with the event.unbind method and the event_type=offline parameter: the function has no parameter that switches the event type.
The function can be called only from an application embedded in the Bitrix24 frame.
If you call the function before BX24.init, the library waits for the initialization and repeats the call, but synchronously returns false. Once the request is sent, the function returns undefined, so the strict check === false tells a refusal from a sent request only inside the BX24.init handler.
Note
The function works only for a user with Bitrix24 administrator rights. For all other users, it synchronously returns false, sends no request, and does not invoke the callback. The restriction comes from the library: the event.unbind method is available to any user, but BX24.js checks the permissions before sending the request.
Parameters
Required parameters are marked with *
|
Name |
Description |
|
event* |
Event name, for example |
|
handler* |
Address of the event handler. The value is compared exactly, including the scheme and the trailing slash |
|
auth_type |
Identifier of the user on whose behalf the event handler is authorized. By default, the parameter is not passed. Choose the value according to how the handler was registered with BX24.callBind:
The parameters are positional: to remove the handlers with any |
|
callback |
Function that handles the result of the method call (detailed description) |
Code Examples
How to Use Examples in Documentation
Remove all handlers of an event registered for an address, regardless of auth_type:
BX24.init(() => {
BX24.callUnbind('ONAPPUNINSTALL', 'https://www.my-domain.com/handler/');
});
Remove the handlers registered without auth_type and process the result:
BX24.init(() => {
BX24.callUnbind(
'ONAPPUNINSTALL',
'https://www.my-domain.com/handler/',
0,
(result) => {
if (result.error())
{
console.error(result.error());
}
else
{
console.log('Handlers removed: ' + result.data().count);
}
}
);
});
Response Handling
The callback function receives an ajaxResult object — the same one as in BX24.callMethod. The data() method returns the response data, and the error() method returns the error.
{
"count": 1
}
Returned Data
|
Name |
Description |
|
count |
Number of the removed event handlers. The value |
Error Handling
{
"status": 400,
"ex": {
"error": "ERROR_ARGUMENT",
"error_description": "Argument 'HANDLER' is null or empty",
"argument": "HANDLER"
}
}
The error code is available as result.error().ex.error, the message as result.error().ex.error_description, and the name of the parameter that caused the error as result.error().ex.argument. The HTTP status is returned by result.error().status and by the getStatus() method, while the toString() method returns a ready string with the code, the message, and the status.
|
Name |
Description |
|
error |
String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only |
|
error_description |
Error message for the developer. Do not show it to the end user without processing |
Possible Error Codes
|
Status |
Code |
Description |
Value |
|
|
|
Argument 'EVENT' is null or empty |
The event name is not passed |
|
|
|
Argument 'HANDLER' is null or empty |
The handler address is not passed |
Errors of the event.unbind method about missing administrator rights never arrive through this function — the request does not reach the server.
Responses with a 5xx status do not reach the callback either. The library throws a Query error! exception from the asynchronous request handler, so a try/catch around the call does not intercept it.
Statuses and System Error Codes
HTTP Status: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |