v1.3.0

HealthCheck.make()

Method for checking the availability of Bitrix24 REST API. Performs a simple request to the REST API to verify service health.

Overview

Use HealthCheck.make() to check the availability of Bitrix24 REST API. The method returns a Promise with a boolean value indicating API availability.

// Basic usage
const isHealthy = await $b24.tools.healthCheck.make()

if (isHealthy) {
  console.log('Bitrix24 API is available')
} else {
  console.error('Problems accessing Bitrix24 API')
}

Method Signature

make(
  options?: { requestId?: string }
): Promise<boolean>

Parameters

ParameterTypeRequiredDescription
requestIdstringNoUnique request identifier for tracking. Used for request deduplication and debugging.

Return Value

Promise<boolean> — a promise that resolves to a boolean value:

  • true — REST API is available and responding, webhook is configured correctly.
  • false — REST API is unavailable, an error occurred, or necessary access rights are missing.

Error Handling

HealthCheck.make() never throws. Network failures, HTTP errors, missing scopes, and timeouts are all collapsed into a return value of false. The method is intentionally a black-box probe — for actionable error information, call the underlying method directly with CallV2.make() and inspect AjaxResult (isSuccess, getErrorMessages()).

Examples

Availability check

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

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

async function checkRestApiHealth(): Promise<boolean> {
  try {
    return await $b24.tools.healthCheck.make({
      requestId: `unique-request-id`
    })
  } catch (error) {
    $logger.error('Health check failed unexpectedly', { error })
    return false
  }
}

// Usage
try {
  const apiAvailable = await checkRestApiHealth()

  if (apiAvailable) {
    $logger.info('Bitrix24 API is available and responding')
  } else {
    $logger.error('Bitrix24 API is unavailable. Check:\n1. Correctness of webhook URL\n2. Bitrix24 availability from your network')
  }
} catch (error) {
  $logger.error('Failed to perform health check', { error })
}

Alternatives and Recommendations

  • For measuring response speed: Use Ping.
  • For checking specific permissions: Perform a test request to the required API method.
  • On the client-side (browser): Use the built-in B24Frame object.