Call a Bitrix24 Method BX24.callMethod
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
void BX24.callMethod(
String method,
Object params[,
Function callback
]
);
The BX24.callMethod function calls a Bitrix24 method on behalf of the user who opened the application. The library automatically adds authorization data to the request and converts the params object into a POST request string.
Values in params can be strings, numbers, arrays, nested objects, and dates. The library passes a date as a string in ISO 8601 format. Instead of a value, you can pass a form field element: for a regular field, the library takes its value, and for an <input type="file"> field without the multiple attribute, the selected file.
The function returns nothing: the result is passed to the callback function. If you call BX24.callMethod before BX24.init, the library defers the request until initialization completes.
The function works only inside the frame of an application and only when the BX24.js library is loaded — the Library Overview describes how to load it.
Parameters
Required parameters are marked with *
|
Name |
Description |
|
method* |
Bitrix24 method name, for example, user.get |
|
params* |
Parameters of the called method. They are listed on the page of that method. If the method has no parameters, pass an empty object |
|
callback |
Function that receives the request result — an ajaxResult object. Without it, the request is executed, but you cannot find out the result |
Code Examples
How to Use Examples in Documentation
Retrieve the user with ID 10. The application needs one of the following scopes for the user.get method: user, user_brief, or user_basic:
BX24.init(() => {
BX24.callMethod('user.get', { ID: 10 }, (result) => {
if (result.error())
{
console.error(result.error());
}
else if (result.data())
{
const user = result.data()[0];
if (user)
{
alert('User №' + user.ID + ' is named ' + user.NAME);
}
}
});
});
Retrieve a list of users page by page. The user.get method returns up to 50 records per call. While result.more() returns true, the result.next() method requests the next page and passes it to the same handler. You cannot pass a non-zero start in params: the library removes it from the request and from the params object itself.
BX24.init(() => {
BX24.callMethod('user.get', { sort: 'ID', order: 'ASC' }, (result) => {
if (result.error())
{
console.error(result.error().toString());
return;
}
console.log(result.data());
if (result.more())
{
result.next();
}
});
});
Upload an employee photo using the user.update method when the user selects a file in a form field. The library reads the selected file and passes it in the PERSONAL_PHOTO parameter. The method requires the user scope, and only an administrator can change another employee's profile:
// <input type="file" id="photo"> — a field on the application page
BX24.init(() => {
const photo = document.getElementById('photo');
photo.addEventListener('change', () => {
if (photo.files.length !== 1)
{
return;
}
BX24.callMethod('user.update', {
ID: 10,
PERSONAL_PHOTO: photo,
}, (result) => {
if (result.error())
{
console.error(result.error().toString());
return;
}
console.log(result.data()); // true
});
});
});
Response Handling
The callback function receives an ajaxResult object. Its answer property stores the Bitrix24 response. An abbreviated example for the user.get method:
{
"result": [
{
"ID": "10",
"ACTIVE": true,
"NAME": "Klaus",
"LAST_NAME": "Weber",
"UF_DEPARTMENT": [1]
}
],
"total": 1,
"time": {
"start": 1790283114,
"finish": 1790283114.0253,
"duration": 0.0253,
"processing": 0,
"date_start": "2026-09-24T20:51:54+00:00",
"date_finish": "2026-09-24T20:51:54+00:00"
}
}
If the list has a next page, the response also contains the next field — the start value for that page. The object's methods make the response easier to read.
ajaxResult Object Methods
|
Method |
What it returns |
|
|
The |
|
|
An error object, or |
|
|
The error message, or |
|
|
|
|
|
The total number of records in the list. If the method did not return it, |
|
|
Requests the next page of the list and passes it to the |
In addition to methods, the object has properties: answer — the Bitrix24 response, status — the HTTP status of the response, query — a copy of the request settings with the method, data, and callback fields. The library adds its own fields to answer. If Bitrix24 returns an error, these include an error object with a reference to the response itself, and JSON.stringify(result.answer) throws an exception. The request execution time is stored in result.answer.time, and there is no separate method for it. The time fields are described in the Time Object section.
Error Handling
The library passes an error returned by Bitrix24 to callback. The result.error() method returns an error object: the ex field contains the Bitrix24 response with the error code and message, and the status field contains the HTTP status. The main fields of the object:
{
"status": 401,
"ex": {
"error": "insufficient_scope",
"error_description": "The request requires higher privileges than provided by the access token"
}
}
The error code is available in result.error().ex.error, and the message in result.error().ex.error_description. The getError() method returns the entire ex object, the result.error().status property and the getStatus() method return the HTTP status, and the toString() method returns a formatted string containing the code, message, and status.
Error codes depend on the called method and are described on its page.
|
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 |
The following are not passed to callback:
- a response with a
5xxstatus, a network failure, and a response that could not be parsed as JSON. The library throws aQuery error!exception from the asynchronous request handler, so atry/catcharound the call does not catch it - the
expired_tokenerror. The library refreshes the authorization itself and retries the request, andcallbackreceives the result of the retry
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 |