Configuring Bitrix24 integration error handling

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1173
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    745
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Setting Up Error Handling for Bitrix24 Integrations

An integration that fails silently is worse than no integration at all. The manager thinks the request went to storage, but it's stuck in a queue with an authorization error three days old. Proper error handling isn't about pretty messages—it's a system that knows about problems before the customer complains.

Typology of Errors in Bitrix24 Integrations

Bitrix24 API errors. Response codes: 200 with error field in body (logical error), 401 (token expired), 429 (rate limit exceeded), 503 (service temporarily unavailable). Each type requires its own response.

External system errors. Logistics returns 400 Bad Request (invalid address), banking API returns 422 Unprocessable Entity (INN not found). These are business errors requiring employee attention, not automatic retry.

Data transformation errors. Mapping data from Bitrix24 to external system format—required field is empty. Or data type mismatch. Such errors occur when structure changes in one of the systems.

Network errors. Connection timeout, DNS unresolved, SSL error. Usually temporary, suitable for automatic retry.

Error Handling Structure

For each integration flow, define three things: what counts as an error, how to respond, who to notify.

Logging. Every request to external system and its response is logged. Minimum set: timestamp, method, input data (with sensitive field masking), response status, error body, execution time. In Bitrix24, use built-in \Bitrix\Main\Diag\Debug::writeToFile() or external stack (Monolog → ELK).

Error classification. In the error handler, determine which class the problem belongs to:

switch (true) {
    case $e instanceof RateLimitException:
        // Wait and retry
        $this->scheduleRetry($job, delay: 60);
        break;
    case $e instanceof AuthException:
        // Refresh token and retry
        $this->refreshToken();
        $this->scheduleRetry($job, delay: 5);
        break;
    case $e instanceof ValidationException:
        // This is a business error—notify manager
        $this->notifyManager($job, $e->getMessage());
        $this->markFailed($job);
        break;
    case $e instanceof NetworkException:
        // Temporary issue—retry with exponential backoff
        $this->scheduleRetry($job, delay: $job->getBackoffDelay());
        break;
}

Notifications. Business errors (data failed validation, counterparty not found)—notify responsible manager via im.notify.system.add in Bitrix24. System errors (service unavailable, authorization error)—notify technical staff via Telegram bot or email.

Error Dashboard

Integration support requires an interface for viewing failed operations. Implemented as a Bitrix24 embedded app or separate admin interface. Shows:

  • List of stuck operations with error description
  • Ability to manually retry operation
  • History of attempts with external system responses

Alternative: error table in custom infoblock or Bitrix24 smart process—then responsible person sees errors directly in CRM without separate interface.

Monitoring and Alerts

Metric Alert Threshold Action
Error rate over 5 minutes > 10% Notify on-call
Error queue size > 100 operations Notify + escalate
Time without successful operations > 30 minutes Critical alert
Expired refresh_token Within 24 hours of expiry Warning

Error handling setup is 20% of code that saves 80% of headaches in production. Systems without error handling require manual intervention at every problem and accumulate "lost" operations that failed without notifying anyone.