Node.js Project
Guide for installing Bitrix24 JS SDK in Node.js applications.
We are still updating this page. Some data may be missing here — we will complete it shortly.
Add to a Node.js project
ESM is the recommended module format.CommonJS is also supported — you can require('@bitrix24/b24jssdk') from a CommonJS project (TypeScript files run directly with ts-node / tsx work too). A UMD build is shipped for <script> usage in the browser.The
CommonJS entry resolves to the UMD bundle, which inlines its dependencies (axios, luxon, qs-esm). That means a require() consumer runs the bundled copy of axios rather than the one in their own node_modules, so npm audit will not flag a future axios advisory inside the SDK bundle until a new SDK version is published. The ESM entry keeps these dependencies external. A dedicated CommonJS build with external dependencies is planned.Before you begin, make sure you have the latest version of Node.js installed.
We support version Node.js
^18.0.0 || ^20.0.0 || >=22.0.0Then run the following command to install the library:
Install the Bitrix24 JS SDK package
pnpm add @bitrix24/b24jssdk
yarn add @bitrix24/b24jssdk
npm install @bitrix24/b24jssdk
bun add @bitrix24/b24jssdk
Import
Import the library into your project.
ESM (recommended):
import { LoggerFactory } from '@bitrix24/b24jssdk'
CommonJS:
const { LoggerFactory } = require('@bitrix24/b24jssdk')
Init
The examples below use
ESMimport syntax. In a CommonJS project, replace each import { X } from '@bitrix24/b24jssdk' with const { X } = require('@bitrix24/b24jssdk').The
B24Hook object is intended exclusively for use on the server.- A webhook contains a secret access key, which MUST NOT be used in client-side code (browser, mobile app).
- For the client side, use
B24Frame
To work with Bitrix24 from a standalone server-side application, use the B24Hook object.
import { B24Hook } from '@bitrix24/b24jssdk'
// 1. Get the webhook URL from Bitrix24:
// - Go to Bitrix24
// - Settings → Developers → Webhooks
// - Create a new webhook with the required permissions
// - Copy the URL in the format: https://your-domain.bitrix24.com/rest/1/your-token/
// 2. Initialize B24Hook
const $b24 = B24Hook.fromWebhookUrl('https://your-domain.bitrix24.com/rest/1/your-token/')
// 3. Use API methods
The
B24OAuth object is intended exclusively for use on the server.- A b24OAuth contains a secret access key, which MUST NOT be used in client-side code (browser, mobile app).
- For the client side, use
B24Frame
To work with Bitrix24 from a standalone server-side application, use the B24OAuth object.
import { B24OAuth } from '@bitrix24/b24jssdk'
// 1. Register an application in Bitrix24:
// - Go to Bitrix24
// - Settings → Developers → Applications
// - Create a new application
// - Get the Client ID and Client Secret
// 2. Initialize B24OAuth — pass token data and OAuth credentials separately.
// See /docs/working-with-the-rest-api/oauth/ for the full B24OAuthParams shape.
import { EnumAppStatus } from '@bitrix24/b24jssdk'
const $b24 = new B24OAuth(
{
applicationToken: 'current_application_token',
userId: 1,
memberId: 'portal_member_id',
accessToken: 'current_access_token',
refreshToken: 'refresh_token',
expires: 1745997853, // unix timestamp, seconds
expiresIn: 3600,
scope: 'crm,user_brief',
domain: 'your-domain.bitrix24.com',
clientEndpoint: 'https://your-domain.bitrix24.com/rest/',
serverEndpoint: 'https://oauth.bitrix.info/rest/',
status: EnumAppStatus.Free
},
{
clientId: 'your_client_id',
clientSecret: 'your_client_secret'
}
)
// 3. Use API methods
// B24OAuth automatically refreshes tokens when they expire