Event for Creating an Application System User ONAPPUSERREADY
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
basicWho can subscribe: the application handler is registered automatically
The ONAPPUSERREADY event is triggered after the application installation is completed successfully, when Bitrix24 has created or reactivated the application system user.
The event handler is registered automatically at the application handler URL used for installation. The handler is transferred together with the application configuration.
Unlike ONAPPINSTALL, the ONAPPUSERREADY event is sent for both immediate and deferred installation completion modes and passes long-lived authorization for the system user. If the application needs to run without an employee's involvement, rely on the ONAPPUSERREADY event.
What the Handler Receives
Data is passed as a POST request in form-encoded format
{
"event": "ONAPPUSERREADY",
"event_handler_id": "17",
"data": {
"access_token": "s1a2b3c4d5e6f70890abcdef1234567890abcd",
"refresh_token": "r1a2b3c4d5e6f70890abcdef1234567890abcd",
"expires_in": "3600",
"scope": "crm,user,task",
"domain": "oauth.bitrix.info",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
"user_id": "512",
"client_id": "app.573ad8a0346747.09223434",
"status": "L",
"LANGUAGE_ID": "de"
},
"ts": "1756890123",
"auth": {
"access_token": "u9z8y7x6w5v4u3t2s1r0q9p8o7n6m5l4",
"refresh_token": "q9z8y7x6w5v4u3t2s1r0q9p8o7n6m5l4",
"expires_in": "3600",
"scope": "crm,user,task",
"domain": "oauth.bitrix.info",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
"user_id": "1",
"status": "L",
"application_token": "0f1e2d3c4b5a69788796a5b4c3d2e1f0"
}
}
The data object contains the system user authorization, and the auth object contains the authorization of the employee who installed the application and the application_token for event verification.
Request Parameters
Required parameters are marked with *
|
Name |
Description |
|
event* |
Symbolic event code. In this case — |
|
event_handler_id |
Event handler ID |
|
data* |
Object with system user authorization parameters. The structure is described below |
|
ts* |
Date and time of the event sent from the event queue |
|
auth* |
Object containing authorization parameters and information about the Bitrix24 account where the event occurred. The structure is described below |
Parameter data
|
Name |
Description |
|
access_token* |
System user access token |
|
refresh_token* |
Token for refreshing the system user authorization |
|
expires_in* |
Access token lifetime in seconds |
|
scope* |
List of permissions granted to the application |
|
domain* |
Authorization server domain |
|
server_endpoint* |
Authorization server address for refreshing OAuth 2.0 tokens |
|
client_endpoint* |
Base path for calling Bitrix24 API methods |
|
member_id* |
Bitrix24 account ID |
|
user_id* |
System user ID in Bitrix24 |
|
client_id* |
Application ID |
|
status* |
Application status. Possible values:
|
|
LANGUAGE_ID* |
Bitrix24 language at the time of application installation |
|
date_finish |
Subscription end date and time, if known to Bitrix24 |
The APP_ID field is not passed in data. The application identifies itself by client_id and member_id.
Parameter auth
|
Name |
Description |
|
access_token* |
Token for API calls |
|
refresh_token* |
Token for refreshing OAuth 2.0 authorization |
|
expires_in* |
Access token lifetime in seconds |
|
scope* |
List of permissions granted to the application |
|
domain* |
Address of the Bitrix24 account where the event occurred |
|
server_endpoint* |
Bitrix24 authorization server address required to refresh OAuth 2.0 tokens |
|
client_endpoint* |
Base path for calling Bitrix24 API methods |
|
member_id* |
ID of the Bitrix24 account where the event occurred |
|
user_id* |
ID of the employee who installed the application |
|
status* |
Application status. Possible values:
|
|
application_token* |
Token for secure event handling |
How to Handle the Event
- Check
auth.application_token - Retain
data.refresh_token,data.member_id, anddata.client_endpoint - Refresh the access token using the standard OAuth refresh flow with the retained
refresh_token - Run background calls to Bitrix24 API methods under the system user authorization
Handler example:
$data = $_POST['data'] ?? [];
$auth = $_POST['auth'] ?? [];
if (($auth['application_token'] ?? '') !== $storedApplicationToken) {
http_response_code(403);
exit;
}
saveSystemUserAuth(
memberId: $data['member_id'],
domain: $data['client_endpoint'],
userId: (int)$data['user_id'],
accessToken: $data['access_token'],
refreshToken: $data['refresh_token'],
expiresIn: (int)$data['expires_in'],
);