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
type

Description

event*
string

Event name, for example ONAPPUNINSTALL. The value is case-insensitive

handler*
string

Address of the event handler. The value is compared exactly, including the scheme and the trailing slash

auth_type
integer

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:

  • 0 or an empty value — handlers registered without auth_type, that is, with the authorization of the user whose actions triggered the event
  • 15 or another user identifier — handlers registered with the auth_type of that user
  • null or an omitted parameter — handlers of the event with any auth_type value

The parameters are positional: to remove the handlers with any auth_type value and receive the result, pass null as the third parameter

callback
function

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
type

Description

count
integer

Number of the removed event handlers. The value 0 means that no handler matched the conditions of the call

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
type

Description

error
string

String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only error_description shows the reason

error_description
string

Error message for the developer. Do not show it to the end user without processing

Possible Error Codes

Status

Code

Description

Value

400

ERROR_ARGUMENT

Argument 'EVENT' is null or empty

The event name is not passed

400

ERROR_ARGUMENT

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
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

429

OPERATION_TIME_LIMIT
Method is blocked due to operation time limit

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

401

NO_AUTH_FOUND
Wrong authorization data

The request contains no authorization data: neither an access token nor a webhook code was passed

401

INVALID_REQUEST
Https required

Methods are called over the HTTPS protocol only

401

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support

401

ACCESS_DENIED
REST is available only on commercial plans

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 — REST is available only by subscription

401

INVALID_CREDENTIALS
Invalid request credentials

No active webhook with the specified user identifier and secret code was found

404

ERROR_METHOD_NOT_FOUND
Method not 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

401

insufficient_scope
The request requires higher privileges than provided by the webhook token

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 provided by the access token

401

expired_token
The access token provided has expired

The access token has expired

401

user_access_error
The user does not have access to the application

The application is installed, but the Bitrix24 administrator has granted access to it only to specific users

403

PORTAL_DELETED
Portal was deleted

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

Continue exploring