Event on New Entries in the Offline Event Queue onOfflineEvent

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

Scope: basic

Who can subscribe: any user

The ONOFFLINEEVENT event is triggered when new entries appear in the offline event queue.

The event replaces polling the queue on a timer: the application receives a signal and retrieves the accumulated entries using the event.offline.get or event.offline.list methods.

Subscribe to ONOFFLINEEVENT only as a regular event — with the handler URL in the handler parameter of the event.bind method. Subscribing with event_type = offline returns the ERROR_ARGUMENT error with the text Offline event cannot be registered for this event: the queue notification itself is not placed into the queue.

Any user can subscribe, but only from an application: event.bind works with OAuth 2.0 authorization only and rejects a webhook call. Entries can be retrieved from the queue using the event.offline.* methods only by an administrator and, again, only in the application context. Read more in the article Offline Events.

Events will not be sent to the application until the installation is complete. Check the application installation

What the Handler Receives

Data is transmitted as a POST request

{
            "event": "ONOFFLINEEVENT",
            "event_handler_id": "185",
            "data": [],
            "ts": "1466439714",
            "auth": {
                "access_token": "s6p6eclrvim6da22ft9ch94ekreb52lv",
                "expires_in": "3600",
                "scope": "crm,task",
                "domain": "some-domain.bitrix24.com",
                "server_endpoint": "https://oauth.bitrix.info/rest/",
                "status": "F",
                "client_endpoint": "https://some-domain.bitrix24.com/rest/",
                "member_id": "a223c6b3710f85df22e9377d6c4f7553",
                "refresh_token": "4s386p3q0tr8dy89xvmt96234v3dljg8",
                "application_token": "51856fefc120afa4b628cc82d3935cce"
            }
        }
        

Request Parameters

Required parameters are marked with *

Name
type

Description

event*
string

Symbolic event code — ONOFFLINEEVENT

event_handler_id*
integer

Identifier of the event handler

data*
array

Arrives empty.

More details below

ts*
timestamp

Date and time the notification was sent from the common event queue

auth*
object

Object containing authorization parameters and data about the Bitrix24 account where the event occurred.

The scope value is the list of permissions granted to the application. The event is basic and does not require a separate scope.

The structure is described below

Parameter data

The event does not transmit data about specific changes but only reports that new entries have appeared in the queue. It carries no payload, so data arrives empty — do not build the handler around parsing this parameter.

To retrieve the events themselves, call event.offline.get or event.offline.list. The structure of a queue entry is described on the pages of these methods.

Parameter auth

Required parameters are marked with *

Name
type

Description

access_token
string

Authorization token OAuth 2.0

expires_in
integer

Time in seconds until the token expires

scope*
string

Scope under which the event occurred

domain*
string

Address of Bitrix24 where the event occurred

server_endpoint*
string

Address of the Bitrix24 authorization server needed to refresh OAuth 2.0 tokens

status*
string

Status of the application that subscribed to this event:

  • Llocal application
  • Ffree mass-market application
  • D — demo version of a mass-market application
  • T — trial version of a mass-market application, time-limited
  • P — paid mass-market application

client_endpoint*
string

Common path for REST API method calls for Bitrix24 where the event occurred

member_id*
string

Identifier of Bitrix24 where the event occurred

refresh_token
string

Token for extending authorization OAuth 2.0

application_token*
string

Token for secure event handling

Authorization tokens are not always passed to the event handler. If the hit that initiated the event could not be linked to a specific Bitrix24 user, the tokens are not passed. Always check the contents of the auth key in the code.

It is recommended to store tokens obtained earlier during the application installation. Use them when working with the application interface in the form of embeds, widgets, and so on.

Notification Frequency

Bitrix24 does not send a separate notification for every queue entry. The minimum interval between notifications is set by the minTimeout parameter in the options object when subscribing with the event.bind method.

This is the only options parameter that ONOFFLINEEVENT supports.

Name
type

Description

minTimeout
integer

Minimum interval between notifications, in seconds. Defaults to 1.

0 — the handler receives one notification per request to Bitrix24, no matter how many entries that request added to the queue.

Greater than 0 — the first trigger sends a notification immediately, the next one is sent no earlier than after the specified number of seconds

Body of the event.bind request for a subscription with a 60-second interval:

{
            "event": "ONOFFLINEEVENT",
            "handler": "https://example.com/handler.php",
            "options": {
                "minTimeout": 60
            }
        }
        

Continue Exploring