Command service

For the interaction with the document command service the POST requests are used. The request parameters are entered in JSON format in the request body. The requests are sent to the http://documentserver/coauthoring/CommandService.ashx address where the documentserver is the name of the server with the ONLYOFFICE Document Server installed.

In ONLYOFFICE Document Server prior to version 4.2 the GET request with the parameters in the QueryString were used.

Parameters and their description:

Parameter Description Type Presence
Defined the type of command.
Supported values:
  • drop - disconnect the users with the identifiers present in the users parameter from the document editing service (these users will be able to view the document, but will not be allowed to make changes to it);
  • forcesave - force saving the document being edited without closing it (the document editing might be continued after this command, so this will not be the final saved document version);
  • info - receive a document status;
  • version - receive the current version number of Document Server.
string required
Defines the document identifier used to unambiguously identify the document file. string required
Defines some custom identifier which will help distinguish the specific request in case there were more than one. string optional
Defines the list of the user identifiers (used for the c=drop parameter value). array of strings optional
{
    "c": "drop",
    "key": "Khirz6zTPdfd7",
    "users": [ "6d5a81d0" ]
}
{
    "c": "forcesave",
    "key": "Khirz6zTPdfd7",
    "userdata": "sample userdata"
}
{
    "c": "info",
    "key": "Khirz6zTPdfd7"
}

The request result is returned in JSON form.

Reply format
{
    "error": 0,
    "key": "Khirz6zTPdfd7"
}
{
    "c": "version"
}

The request result of version is returned in JSON form.

Reply format
{
    "error": 0,
    "version": "4.3.1.4"
}

The document editing service informs the document storage service about the result caused by command using the callback handler.

Possible error codes and their description
Error code Description
0 No errors.
1 Document key is missing or no document with such key could be found.
2 Callback url not correct.
3 Internal server error.
4 No changes were applied to the document before the forcesave command was received.
5 Command not correсt.
6 Invalid token.