Version 1.0.1 is now available! Looking for a migration guide?
v1.0.1
/
  • Get Started
  • Working
  • GitHub
  • Overview
  • Introduction
  • Actions
  • Call
  • Call
  • CallList
  • CallList
  • FetchList
  • FetchList
  • Batch
  • Batch
  • BatchByChunk
  • BatchByChunk
  • Tools
  • HealthCheck
  • Ping
  • Logger
  • Logger
  • Telegram
  • Limiters
  • Limiters
  • B24Frame
  • Introduction
  • Initialization
  • Auth
  • Dialog
  • Options
  • Parent
  • Placement
  • Slider
  • b24ui
  • b24icons
v1.0.1
  • Get started
  • Working

CallV2.make

A method for making Bitrix24 REST API version 2 calls.
CallV2
AjaxResult
AjaxError
SdkError
We are still updating this page. Some data may be missing here — we will complete it shortly.
Bitrix24 is gradually transitioning to REST API version 3.
  • When calling methods available in REST API v3, the method automatically logs a warning.

Overview

Use CallV2.make() to call REST API version 2 methods.

The method returns a Promise with an AjaxResult object containing response data, status, and error handling methods.

// Basic usage
import { EnumCrmEntityTypeId } from '@bitrix24/b24jssdk'

const response = await $b24.actions.v2.call.make({
  method: 'crm.contact.get',
  params: {
    entityTypeId: EnumCrmEntityTypeId.contact,
    id: 123
  },
  requestId: 'unique-request-id'
})

Method Signature

make<T = unknown>(
  options: ActionCallV2
): Promise<AjaxResult<T>>

Parameters

The options object contains the following properties:

ParameterTypeRequiredDescription
methodstringYesREST API method name (e.g., crm.contact.get, tasks.task.get).
paramsTypeCallParamsNoObject with parameters to pass to the REST API method.
requestIdstringNoUnique request identifier for tracking. Used for request deduplication and debugging.

Return Value

Promise<AjaxResult<T>> — a promise that resolves to an AjaxResult object.

This object provides:

  • .getData(): Payload<T> — returns the REST API response.
  • .isSuccess: boolean — flag indicating successful request execution.
  • .getErrorMessages(): string[] — array of error messages.
  • .isMore(): boolean — indicates the presence of additional data during pagination.

Key Concepts

Automatic Warning

When calling methods that are available in REST API version 3, the system automatically logs a warning:

"The method {method_name} is available in restApi:v3. It's worth migrating to the new API."

This indicates that you should consider migrating to the newer REST API version.

Error Handling

Always check the result using isSuccess and handle errors:

const response = await $b24.actions.v2.call.make({
  method: 'some.method',
  params: { /* some_params */ },
  requestId: 'unique-request-id'
})

if (!response.isSuccess) {
  // Handling error
  console.error(new Error(`Error: ${response.getErrorMessages().join('; ')}`))
  return
}

// Working with a successful result
const data = response.getData()

Examples

Getting a CRM Company

import { B24Hook, EnumCrmEntityTypeId, LoggerFactory, SdkError, AjaxError } from '@bitrix24/b24jssdk'

type Company = {
  id: number
  title: string
  [key: string]: any
}

const devMode = typeof import.meta !== 'undefined' && (import.meta?.dev || globalThis._importMeta_.env?.DEV)
const $logger = LoggerFactory.createForBrowser('Example:getCrmItem', devMode)
const $b24 = B24Hook.fromWebhookUrl('https://your_domain.bitrix24.com/rest/1/webhook_code/')

async function getCrmItem(entityTypeId: number, itemId: number, requestId: string): Promise<Company | null> {
  const response = await $b24.actions.v2.call.make<{ item: Company }>({
    method: 'crm.item.get',
    params: {
      entityTypeId: entityTypeId,
      id: itemId
    },
    requestId
  })

  if (!response.isSuccess) {
    throw new SdkError({
      code: 'MY_APP_GET_PROBLEM',
      description: `Problem ${response.getErrorMessages().join('; ')}`,
      status: 404
    })
  }

  return response.getData()!.result?.item
}

// Usage
const itemId = 528
const requestId = `crm-item-${itemId}`
try {
  const entity = await getCrmItem(EnumCrmEntityTypeId.company, itemId, requestId)
  $logger.info(`Entity [${entity?.id}]`, { entity })
} catch (error) {
  if (error instanceof AjaxError) {
    $logger.critical(error.message, { requestId, code: error.code })
  } else {
    $logger.alert('Problem', { requestId, error })
  }
}

Alternatives and Recommendations

  • For working with lists: Instead of manually managing pagination use:
    • CallList — automatically retrieves all pages and returns a single result.
    • FetchList — returns an async generator for step-by-step processing of large lists.
  • For batch operations: Use Batch to execute up to 50 commands in a single request.
  • On the client-side (browser): Use the built-in B24Frame object.

Introduction

Overview of SDK capabilities for working with Bitrix24 REST API

CallList

Method for quickly retrieving all data from list methods of Bitrix24 REST API version 2.

On this page

  • Overview
  • Method Signature
    • Parameters
    • Return Value
  • Key Concepts
    • Automatic Warning
  • Error Handling
  • Examples
    • Getting a CRM Company
  • Alternatives and Recommendations
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24