Event of Queue Change onOfflineEvent

Who can subscribe: any user

The onOfflineEvent notifies about the occurrence of new offline events at certain intervals.

The application can subscribe to two types of events.

  • Regular: the event triggers an external URL and performs an action defined by that address.
  • Offline: instead of calling an external URL, events are locally saved on the account, from where they can later be retrieved using the methods event.offline.*.

For the onOfflineEvent, the necessity of sending a notification is determined based on the local saving, and then it is sent as a regular event to the external URL.

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",
          "data": {
            "type": "add",
            "event": "onTaskAdd",
            "handler": "https://example.com/handler.php", 
            "minTimeout": 5
          },
          "ts": "1466439714",
          "auth": {
            "access_token": "s6p6eclrvim6da22ft9ch94ekreb52lv",
            "expires_in": "3600",
            "scope": "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 code of the event — ONOFFLINEEVENT

data*
array

Data about the event in the queue.

The structure is described below

ts*
timestamp

Date and time of the event sending

auth*
array

Authorization and account data.

The structure is described below

Parameter data

Required parameters are marked with *

Name
type

Description

type*
string

Type of change: add, remove, update

event*
string

Name of the event. For example, onTaskAdd

handler*
string

URL of the event handler

minTimeout
integer

Minimum delay before sending the event in seconds. Used for event grouping. Default is 1 sec. If the parameter value:

  • is 0, regardless of the number of events added to the offline queue, only one event will be sent to the handler's address within one hit
  • is greater than 0, upon the first trigger, it sends one event. Then a pause is made for at least the timeout duration before sending the next event

The minTimeout field appears only if the event is added to the queue with a delay

Parameter auth

Required parameters are marked with *

Name
type

Description

access_token*
string

Token for accessing the API

expires_in*
integer

Time in seconds until the token expires

scope*
string

Scope within which the event occurred

domain*
string

Address of Bitrix24 where the event occurred

server_endpoint*
string

Address of the Bitrix24 authorization server needed for refreshing OAuth 2.0 tokens

status*
string

Status of the application that subscribed to this event:

client_endpoint*
string

General path for 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 processing

offline_event — the application is not always able to receive events. It may be hidden behind firewalls, reside in an internal network, and so on. In this case, the offline event mechanism is used, where the application subscribes to events but does not specify a handler URL.

Continue Learning