Documentation Index
Fetch the complete documentation index at: https://mintlify.com/R0N7w7/OnlyOfficeControl/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Thecallback action receives POST requests from the OnlyOffice Document Server when document editing events occur. This is primarily used to save document changes back to the server storage when users finish editing.
Endpoint
Query Parameters
Must be set to
callback to invoke this actionThe unique identifier of the file being edited. Used to locate and update the stored file.
Request Body
The request body must be a JSON object with the following structure:The document status code from OnlyOffice Document Server:
2- Document is ready for saving (user clicked save)6- Document is being edited, force save requested- Other status codes are ignored by this handler
The URL where the updated document can be downloaded from OnlyOffice Document Server. The handler will fetch the document from this URL and save it to storage.
Request Example
Payload Class Structure
Response
The callback action always returns a JSON response indicating success or failure.Success Response
HTTP status code indicating success
Response content type
Error code where
0 indicates successExample Success Response
Error Response
HTTP status code (note: still returns 200 even on error)
Response content type
Error code where
1 indicates failureExample Error Response
Status Codes
The handler only processes callbacks with specific status codes:Status Code 2: Document Ready for Saving
Indicates that the document is ready to be saved. This typically occurs when:- A user clicks the save button
- A user closes the document
- Co-editing session ends
Status Code 6: Force Save
Indicates a force save event. This typically occurs when:- The application explicitly requests a document save
- Periodic auto-save is triggered
- Co-editing session requires synchronization
Ignored Status Codes
Other status codes (0, 1, 3, 4, 7) are ignored by this handler and will return success without performing any file operations:0- Document not found1- Document is being edited3- Document saving error4- Document closed with no changes7- Error during force save
File Update Process
When a valid callback is received (status 2 or 6), the handler performs the following steps:Step 1: Parse Request Body
Read and deserialize the JSON payload from the request body:Step 2: Validate Payload
Check that the payload contains valid data:- Status is 2 or 6
- URL is not null or whitespace
- File exists in storage
Step 3: Download Updated Document
Fetch the updated document from the OnlyOffice Document Server:Step 4: Save to Storage
Overwrite the existing file with the updated content:Error Handling
The callback action wraps all processing in a try-catch block:- Invalid JSON payload
- Network errors when downloading from OnlyOffice server
- File system errors when writing to storage
- Missing or invalid fileId parameter
Implementation Details
Source Code Reference
The callback action is implemented in:Code Example
Usage in OnlyOffice Document Server
The callback action is configured in the OnlyOffice Document Server editor configuration:Security Considerations
Security Risks
- Unauthenticated Requests: Any client can send callback requests
- File Overwriting: Malicious requests could overwrite files
- URL Injection: Arbitrary URLs could be provided in the payload
Recommended Security Measures
1. JWT Token Validation
OnlyOffice Document Server supports JWT tokens for secure callbacks:2. IP Whitelist
Restrict callbacks to your OnlyOffice Document Server IP:3. URL Validation
Ensure the callback URL originates from your OnlyOffice server:4. File Access Control
Verify user permissions before updating files:TLS Configuration
The handler configures secure protocols before making external requests:Related Actions
Download Action
Download documents from server storage
Proxy Action
Proxy external document requests