# Migrate from ONLYOFFICE

Source: https://mroffice.ai/en/developers/embed/onlyoffice

If your product already integrates ONLYOFFICE Docs, MR Office can answer in its place. Turn on ONLYOFFICE compatibility for an embed app and it gets a Document Server URL, https://mroffice.ai/oo/<app id>/. Behind it MR Office serves DocsAPI.DocEditor, calls your callback handler in ONLYOFFICE's format, and answers the Conversion API and the Command service. Your pages and your server keep the code they have.

> This is MR Office's own implementation of ONLYOFFICE's public integration contract. No ONLYOFFICE code runs: the editors are MR Office's, with their own look and features.

### Change one URL

- In the developer console, create an embed app (or open one) and add the origin of the site that shows the editor to its allowed origins.
- Under ONLYOFFICE compatibility, paste the JWT secret your integration already signs with, then turn the switch on.
- Copy the app's Document Server URL and put it where your integration names its Document Server (the address it loads api.js from and sends command and conversion requests to).
- Open a document. The compatibility report in the console lists every config field, event and method your integration used that MR Office does not.

The only change in a page:

```html
<!-- before -->
<script src="https://docs.example.com/web-apps/apps/api/documents/api.js"></script>

<!-- after: the Document Server URL of your app, from the developer console -->
<script src="https://mroffice.ai/oo/<app id>/web-apps/apps/api/documents/api.js"></script>

<script>
  // Unchanged: the same config, the same token signed with the same secret.
  const docEditor = new DocsAPI.DocEditor("placeholder", config);
</script>
```

### JWT

- config.token is verified with the app's secret (HS256, HS384 or HS512; exp and nbf are honoured). A config without a valid token opens nothing.
- What decides access is read from the token alone: document.key, document.url, document.permissions, editorConfig.callbackUrl and editorConfig.mode. A value the page sets beside the token changes nothing. The other fields are the token's when it has them, else the page's.
- MR Office downloads document.url with Authorization: Bearer <JWT of {"payload": {"url": …}}>, and signs every callback the same way (or in the body's token field, a console switch), so handlers that verify ONLYOFFICE's tokens verify these.
- Requests to the Command service and the Conversion API need a token signed with the same secret, in the body or the header.
- Require JWT can be switched off for testing; unsigned configs and requests are then accepted from localhost only.
- An integration that keeps ONLYOFFICE's secrets apart (secret.browser, secret.inbox, secret.outbox) sets an inbox and an outbox secret in the console too: the inbox one verifies requests to the Command service, the Conversion API and the Document Builder service, the outbox one signs callbacks and file downloads. config.token stays the main secret's.

### What your config becomes

| Config | MR Office |
| --- | --- |
| document.fileType, documentType | Chooses the editor by the file's type: Word (docx, doc, odt, rtf, txt…), Excel (xlsx, xls, ods, csv…), PowerPoint (pptx, ppt, odp…) or PDF. The file is saved back in its own format. |
| document.key | The document: everyone opened with the same key edits together. Use a new key after each saved version, as with ONLYOFFICE. |
| document.url | Fetched by MR Office over https, with the signed Authorization header. |
| document.title | The file's name in the editor. |
| document.permissions.edit / review / comment / fillForms | The access mode. edit: full editing (review: false removes accept/reject). review without edit: every change is tracked. fillForms alone: form fields only. comment alone: comments only. None of them, or mode view: read-only. Review, comment and form filling are the Word editor's; other files open read-only in them. |
| document.permissions.download / print / copy | Enforced by the server and the editor: no export or download, no print, no copying out. |
| permissions.editCommentAuthorOnly / deleteCommentAuthorOnly | People manage only their own comments. |
| editorConfig.callbackUrl | Receives the callbacks below. Without it the document opens read-only. |
| editorConfig.mode | view opens read-only whatever the permissions say. |
| editorConfig.lang | The editor's language (20 languages; the closest one, else English). |
| editorConfig.user.id / name / image | The person's id in callbacks, their name and picture (https) for the other editors. |
| customization.forcesave | true: Save in the editor sends status 6 with forcesavetype 1. |
| customization.comments | false hides the comments pane. |
| customization.macros, macrosMode | Document macros: on by default; false, or macrosMode "disable", turns them off. Macros someone else wrote run only after the person enables them. VBA is kept in the file and never run, as in ONLYOFFICE. |
| editorConfig.plugins.pluginsData, customization.plugins | ONLYOFFICE plugins as they are published: each config.json URL opens in the editor's Plugins panel and tab on window.Asc.plugin; customization.plugins false leaves them out (see Plugins). |
| customization.uiTheme | theme-light, default-light, theme-classic-light, theme-white and theme-gray open the editor light; theme-dark, default-dark and theme-night dark; theme-contrast-dark in high contrast; theme-system as the device is. |
| customization.logo.image | Shown while the editor opens and in its header (logo.url links it), for apps on Pro and above (white label). |
| type, width, height | embedded hides the toolbar; width and height size the frame. |
| token | Required (see JWT). |
| permissions.commentGroups / reviewGroups / userInfoGroups, user.group | Who sees whose name, and whose comments and tracked changes a person may manage (see Group permissions). |
| permissions.protect / modifyFilter / modifyContentControl | false: protection, the shared filter or the content controls cannot be changed (see Group permissions). |
| editorConfig.user.roles | The person's form role: the first role fills its fields of a PDF form, and the fields given to no role. |
| customization.goback / close | Open file location and a close button in the header: goback.url opens in a new tab (blank) or in place; requestClose and close call onRequestClose. |
| customization.help / feedback | help: false takes Help out of the File menu (MR Office's help is its command search). feedback.url adds Feedback & support. |
| customization.compactToolbar / toolbarNoTabs / toolbarHideFileName | The ribbon opens folded to its tab row (the person may unfold it); toolbarHideFileName hides the file's name. |
| customization.zoom | The zoom the editors open at, in percent. |
| customization.review.trackChanges / reviewDisplay | trackChanges turns Track Changes on or off as the Word editor opens; reviewDisplay markup, simple or final is Word's All Markup, Simple Markup or No Markup (original shows All Markup). |
| customization.autosave | false: the app's autosave does not save the document while such a person edits; their Save, a forcesave and the closing save still do. |
| customization.submitForm | false: a form opened to fill has no Submit button. |
| document.info.favorite | Shows the favourite star in the header; a click calls onMetaChange, and setFavorite() sets the star. |

### Ignored fields

Everything else in the config is accepted and ignored: the document still opens. Each ignored field is counted in the app's compatibility report in the developer console, with the reason. The most common:

- permissions.chat, customization.chat: MR Office has no chat.
- customization.about, hideRightMenu, hideRulers, hideNotes, unit, font, features.*, layout.*, anonymous, review.hoverMode: the editor keeps its own interface.
- onRequestReferenceSource, setReferenceSource(), onRequestOpen: a link's source is neither changed nor opened from the editor (Update values reads it: see Events and methods).
- editorConfig.createUrl, templates, recent, coEditing, embedded, actionLink and onMakeActionLink, setSharingSettings(), requestRoles(), createConnector(): not used.

### Callbacks

Your callback handler receives the same JSON as from ONLYOFFICE and answers {"error": 0}. Any other answer is retried (10 s, 30 s, 2 min … 6 h) and listed in the console's deliveries.

| status | When |
| --- | --- |
| 1 | Someone joins, or leaves while others stay: users and actions (type 1 / 0). |
| 2 | About 10 seconds after the last editor left, when the document changed since it was opened: url is the saved file in its own format (filetype), users the last editor; history.changes lists each version MR Office saved in the cycle (when, who), and changesurl is a ZIP of changes.json and the file the cycle began from. |
| 3 | The closing save failed. |
| 4 | The last editor left and nothing changed. |
| 6 | A save while people still edit: forcesavetype 0 (Command service), 1 (Save with customization.forcesave), 2 (the app's autosave), 3 (a form submitted in the editor: formsdataurl is its values as JSON, [{key, value, type}]). |
| 7 | A force save failed. |

### Command service and Conversion API

Server requests:

```bash
# The Command service and the Conversion API, at the same base URL
POST https://mroffice.ai/oo/<app id>/command            # or /coauthoring/CommandService.ashx
POST https://mroffice.ai/oo/<app id>/converter          # or /ConvertService.ashx
POST https://mroffice.ai/oo/<app id>/docbuilder

# The token as before: in the body ({"token": "<JWT of the parameters>"})
# or in the header (Authorization: Bearer <JWT of {"payload": parameters}>).
```

| Request | MR Office |
| --- | --- |
| info | The editors in the document; status 1 is sent to the callbackUrl with userdata. Error 1 when nobody is editing the key. |
| forcesave | Saves now and sends status 6 (forcesavetype 0, userdata). Error 4 when nobody edited since the last save. |
| drop | Ends the editing sessions of users (of everyone without users). Their editor reopens the document read-only, as ONLYOFFICE leaves them a read-only view. |
| meta | Renames the document (meta.title) and sets its favourite (meta.favorite). Open editors show the new name and call onMetaChange within a few seconds. |
| version | The Docs API level MR Office answers as. |
| getForgotten / getForgottenList / deleteForgotten | A closing save your handler did not accept is kept as the document's forgotten file. |
| license | ONLYOFFICE's license, server and quota objects, from the app's plan: connections is its open-session cap, users_count its monthly sessions, trial is true on the Free plan, customization true with white label. |
| converter | filetype, outputtype (ooxml and odf included), url, key, title, async and thumbnail (first, width, height, aspect). The answer is XML, or JSON with Accept: application/json. Each conversion counts in the app's conversion allowance. |
| converter: codePage, delimiter | codePage (a Windows code page: 65001 UTF-8, 1252, 932, 936…) and delimiter (1 tab, 2 semicolon, 3 colon, 4 comma, 5 space) read a CSV or text file in its own encoding and delimiter, as ONLYOFFICE reads them. |
| docbuilder | Runs the .js script at url on MR Office's Document Builder with its argument; async and key work as ONLYOFFICE's. The answer is {key, end, urls}: each file the script saved, by its name. Errors -1 to -8 as ONLYOFFICE's. One build counts once in the app's conversion allowance. |
| converter: password | An encrypted Office file (Agile or Standard Encryption) or a PDF with a password opens with it; without it, or with a wrong one, the answer is error -5. |
| converter: spreadsheetLayout | A workbook written to PDF or page images is laid out by fitToWidth, fitToHeight, orientation, margins, pageSize, scale, gridLines, headings and ignorePrintArea, written into each sheet's page setup first. |
| converter: watermark | The text of its paragraphs is stamped over every page of a PDF or page-image result, in its fill colour, at its rotate angle, transparency and font size. |
| converter: documentLayout, documentRenderer, pdf, region | MR Office's PDF never draws placeholders or form highlights (drawPlaceHolders or drawFormHighlight true is reported). pdf.form true writes a Word document's content controls as the PDF's form fields. outputtype pdfa writes PDF/A-2b, checked by veraPDF. A PDF, XPS or DjVu converts to Word (ooxml) or OpenDocument text by the PDF editor's conversion, its lines joined into paragraphs (another documentRenderer.textAssociation is reported). region (en-US, fr-FR…) writes a workbook's system date, time and currency formats as that region shows them. |
| converter: error | -1 unknown, -2 not finished in time, -3 conversion, -4 download, -5 password, -6 the result was deleted after its retention, -7 input, -8 token, -9 ooxml or odf for a file that is neither, -10 size. |
| converter/from-file | Docs 10's file upload request: a multipart body with params (the converter's parameters but url), file and token. The answer is the converted file itself, {endConvert, percent} while it runs, or {error}; sent again without the file, it answers the conversion its key names. |

### Events and methods

| DocsAPI | MR Office |
| --- | --- |
| onAppReady, onDocumentReady, onInfo | Fired when the document is open in the editor. |
| onDocumentStateChange | true when the document has unsaved changes, false when it is saved. |
| onError, onWarning | A failure that stops the editor, or one that does not. errorDescription is MR Office's message; mrofficeCode its error code. |
| onRequestUsers + setUsers() | @mentions in comments ask your page for people (c: "mention", search); answer with setUsers. |
| onRequestSendNotify | A comment that mentions people was posted: message and emails. |
| onDownloadAs + downloadAs() | Exports the document as it is now: url is a link of MR Office's to the file, title its name. |
| onRequestClose + requestClose() | The header's close button and Open file location (with goback.requestClose) call onRequestClose; so does requestClose(). |
| destroyEditor(), showMessage() | Supported. |
| onRequestHistory + refreshHistory(), onRequestHistoryData + setHistoryData(), onRequestRestore, onRequestHistoryClose | The editor's Version history: see below. setHistoryData's token is verified; its url, previous.url and changesUrl are fetched by MR Office. |
| onRequestSaveAs | File > Save copy as: { fileType, title, url }, the url a link of MR Office's. |
| onRequestRename, onMetaChange, setFavorite() | The file's name in the header asks onRequestRename (the new name); your meta command renames it and calls onMetaChange. |
| onRequestInsertImage + insertImage() | Insert > Image from storage: insertImage({ c, images, token }) puts the pictures at the cursor (Word), over the selected cell (Excel), on the slide (PowerPoint) or centred on the page shown (PDF). |
| onRequestSelectSpreadsheet + setRequestedSpreadsheet() (setMailMergeRecipients()) | Mail merge: setRequestedSpreadsheet({ fileType, url, token }) gives the recipients; Merge fills the document once each. |
| onRequestSelectDocument + setRequestedDocument() (setRevisedFile()) | Compare with document: setRequestedDocument({ c: "compare", fileType, url, token }) shows the differences; Text from file: c: "insert-text" inserts the file's text at the cursor. |
| onRequestEditRights, denyEditingRights() | A reader's Edit button calls onRequestEditRights; denyEditingRights(message) takes it away. |
| onOutdatedVersion, onRequestRefreshFile + refreshFile() | A key whose saved version your handler took opens read-only and calls onRequestRefreshFile (answer refreshFile(config): the editor opens it without being made again), else onOutdatedVersion. |
| onRequestStartFilling + startFilling(), onStartFilling, onSubmit | File > Start filling (a PDF form) calls onRequestStartFilling; startFilling() reopens it to fill and calls onStartFilling. Submit in a fillForms session sends status 6 / forcesavetype 3, then onSubmit. |
| onRequestReferenceData + setReferenceData() | Data > Update values (a workbook's links to other workbooks): onRequestReferenceData asks for each source ({ referenceData, path, link }); setReferenceData({ fileType, path, referenceData, url, token }) reads it, and the formulas that read it are calculated again. |
| setActionLink(), setSharingSettings(), requestRoles(), createConnector() | Do nothing; a console warning says so once, and the report counts them. |

### Version history, Save copy as and the editor's other dialogs

- MR Office's editor shows the commands your page handles in a header above the document: the logo (customization.logo, white label), Open file location (goback), the file's name (onRequestRename), the favourite star (document.info.favorite), Edit for a reader (onRequestEditRights), Close (onRequestClose) and a File menu.
- Version history (onRequestHistory): the versions your refreshHistory() gives are listed with their author and time. A click asks onRequestHistoryData, and the version your setHistoryData() names is shown page by page. A Word version with previous.url, or with the changesUrl MR Office sent, is compared with the version before it: its changes are drawn as tracked changes and listed. Restore calls onRequestRestore; closing the pane calls onRequestHistoryClose.
- What MR Office sends for your history: each status 2 has history.changes (every version it saved in the cycle, its author and time) and changesurl, a ZIP of changes.json and the file the cycle began from. Store it as ONLYOFFICE's diff.zip and hand it back as changesUrl.
- Save copy as (onRequestSaveAs): the document as it is now, in the format chosen (its own, PDF, ODF or the older Office format), at a link of MR Office's. downloadAs() answers onDownloadAs the same way.
- Image from storage (onRequestInsertImage, then insertImage()): MR Office fetches the pictures (signed as its downloads are), checks them and inserts them at the cursor of a Word document, over the selected cell of a workbook, on the slide shown or centred on the PDF page shown; a picture larger than 2 MB is made smaller.
- Mail merge (onRequestSelectSpreadsheet, then setRequestedSpreadsheet()): the recipients' CSV or workbook is read into fields; a click on a field inserts it as {{Field}}; Merge fills the document once a recipient with the app's template job (one Word file, or a file each, in Word or PDF), counted as one generation per recipient.
- Compare with document (onRequestSelectDocument, then setRequestedDocument()): the document is compared with the .docx you name, word by word; the differences are drawn and listed.
- Forms: Start filling (onRequestStartFilling, then startFilling()) reopens a PDF form to fill; Submit sends status 6 with forcesavetype 3 and formsdataurl, then onSubmit.
- drop: the person's editor reopens the document read-only.

### Group permissions and what enforces them

- userInfoGroups (with user.group): the server names the other people of the document only to people of the groups listed; the others appear without a name or picture.
- commentGroups: in the Word editor, comments by people of other groups are not listed (view), resolved or edited (edit) or deleted (remove); the server refuses a save or a live edit that changes them, as it does under editCommentAuthorOnly and deleteCommentAuthorOnly.
- reviewGroups: in the Word editor, tracked changes by people of other groups cannot be accepted or rejected, one by one or all at once; the server refuses a write that does.
- protect false: Restrict Editing, Protect Sheet, Protect Workbook and the PDF editor's Protect tab are not offered, and the server keeps the document's, the sheets' and the workbook's protection as they are.
- modifyFilter false: the AutoFilter and its criteria cannot be changed, and the server keeps the workbook's filter as it is (a row or column inserted in its range is no change). MR Office has no filter of one person's own, which ONLYOFFICE applies locally instead.
- modifyContentControl false: content controls can be neither filled nor deleted.
- The mode, download, print, copy, form roles, userInfoGroups, commentGroups, reviewGroups, protect and modifyFilter are enforced by the server (a page save, the live rooms); modifyContentControl by the editor in the frame.

### Differences to know

- Allowed origins: MR Office frames the editor only in pages of the origins the app lists. ONLYOFFICE has no such list.
- Saved format: the file comes back in the format it was opened in (a .doc stays a .doc), as ONLYOFFICE does with assemblyFormatAsOrigin. Office files nobody changed come back byte for byte.
- changesurl is MR Office's ZIP of the cycle's changes (changes.json) and the file the cycle began from, not ONLYOFFICE's change set: store it and hand it back as ONLYOFFICE's, and MR Office's version history reads it.
- A key whose saved version your handler took (status 2) is outdated, as in ONLYOFFICE: it opens read-only and calls onRequestRefreshFile or onOutdatedVersion. Keep generating new keys.
- An integration that builds URLs from the server root (a path beginning with /) instead of appending to the base URL must set its path settings to /oo/<app id>/….
- Plans, limits and usage are the embed app's: sessions, documents and conversions count as for any embedded editor.
- A closing save, a forcesave and an autosave write the file as its format can hold it, without asking anyone, so your handler always receives the edited file. Save in the editor asks the person first when something would be lost. What such a save gave up is never silent: it is listed in the console's Events (save.losses_accepted) and compatibility report, and the callback carries it as mroffice.lossesAccepted ({ reason, codes, count }).
- autosave: false stops the app's autosave (forcesavetype 2) while such a person edits; MR Office's editors keep each change in the document as it is typed, as ONLYOFFICE's Strict co-editing does.
- Plugins run as they are: MR Office gives an ONLYOFFICE plugin's pages window.Asc.plugin, and its callCommand the common Document Builder calls (see Plugins). Macros use MR Office's own object model, named after Office.js; ONLYOFFICE macro code (Api.GetDocument()…) needs porting.

### Try it with ONLYOFFICE's example

ONLYOFFICE's open-source integration example (Node.js) runs against MR Office unmodified. Create an app, allow localhost in its origins, turn compatibility on with a secret, then:

ONLYOFFICE's Node.js example, pointed at MR Office:

```bash
git clone --recurse-submodules https://github.com/ONLYOFFICE/document-server-integration
cd document-server-integration/web/documentserver-example/nodejs

docker run --rm -p 3080:3000 -v "$PWD":/app -w /app \
  -e NODE_CONFIG='{"server":{"siteUrl":"https://mroffice.ai/oo/<app id>/","exampleUrl":"https://<public address of this example>","token":{"enable":true,"secret":"<your JWT secret>"}}}' \
  node:20 sh -c "npm ci && npm start"
```

> The example must be reachable by MR Office over https (its exampleUrl) for the file download and the callbacks. Open http://localhost:3080, upload a .docx, edit it and close the tab: its /track handler receives status 2 and stores the file.
