# Errors and debugging

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

Every error has a stable code. onError and every rejected promise carry it with message, fatal, hint (what to do) and docs (a link to its row below); the API answers with the same codes as { "error": { "code", "message" } }.

| Code | What to do |
| --- | --- |
| embed_token_invalid | The token did not verify. Sign it HS256 with the app's secret key (mro_sk_…), set iss to your app ID and aud to "mroffice-embed"; the message says which claim failed. |
| embed_token_expired | The token's exp has passed. Mint a token per page load, just before open(); exp − iat of 600 seconds is a good value. |
| embed_token_replayed | Each token starts one session, once (its jti). Pass token as a function that fetches a new one, so a reload or setMode gets a fresh token. |
| embed_token_ttl_too_long | exp − iat is at most 3600 seconds. The token only starts the session; the session itself lasts 10 hours. |
| embed_token_missing | open() was given no token. Pass token: a string your server signed, or a function that fetches one. |
| embed_token_required | This step needs a new token (a reload, setMode, setLocale or a session about to end). Pass token as a function, or refreshToken. |
| embed_api_key_invalid | The secret key is wrong, retired or rotated. Copy the current one from the developer console. |
| embed_api_key_required | Send the secret key as Authorization: Bearer mro_sk_… on server-to-server API calls. |
| embed_no_usable_key | The app has no active secret key. Rotate one in the developer console. |
| embed_refresh_failed | refreshToken() (or your token function) threw or returned nothing. Check your token endpoint. |
| embed_origin_not_allowed | This page's origin is not one of the app's allowed origins. Add it (exact scheme, host and port) in the developer console; while building on your computer, turn on Allow localhost. |
| embed_invalid_origin | An allowed origin is scheme://host[:port]: https, no path, no wildcard (Allow localhost covers http://localhost:* and http://127.0.0.1:*). |
| embed_app_not_found | No app has this ID. Check appId and the token's iss against the developer console. |
| embed_app_disabled | The app is disabled. Enable it in the developer console. |
| embed_unavailable | The editor could not read the app's settings. Check the app ID; if it is right, retry in a moment. |
| embed_not_available | Embedding is not available for this account. |
| embed_file_fetch_failed | MR Office could not download file.url. It must be a public https URL answering 200 within 60 seconds (a signed link to your storage is ideal). |
| embed_file_fetch_refused | file.url points to a private or local address, which MR Office never fetches. Use a public https URL, or upload the file first. |
| embed_file_too_large | The file is larger than the app's (or the token's max_bytes) limit. |
| embed_file_unsupported | The editors open .docx .xlsx .pptx .pdf, and .doc .dot .dotx .rtf .odt .txt .md .html .xls .xltx .ods .csv .tsv .ppt .potx .odp (see Supported formats). |
| embed_file_invalid | The file's name needs its extension (.docx, .xlsx, .csv…: see Supported formats), and its bytes must be that kind of file. |
| embed_file_empty | The file is empty. |
| embed_file_not_readable | The file's bytes are not a readable Office or PDF file (damaged, encrypted, or another format renamed). |
| embed_import_failed | The file could not be opened. Try it in MR Office itself; if it opens there, contact support with the file key. |
| embed_upload_not_found | The token names an upload_id that does not exist for this app. |
| embed_upload_expired | Uploads must be named in a token within 24 hours. Upload the file again. |
| embed_document_version_conflict | People are editing another version of this file key. Give the new version a new file.key, or wait until the open sessions end. |
| embed_document_kind_mismatch | A file key keeps one kind of file. Use a new file.key for a different file. |
| embed_document_in_use | Others have this document open; a local file replaces it only when no one else is in it. |
| embed_document_has_file | This file key already holds a document. Mint the token with file.replace: true to let the person replace it. |
| embed_document_full | Too many people are in this document at once. |
| embed_local_files_not_allowed | Turn on "Allow people to open files from their computer" for the app in the developer console. |
| embed_local_not_granted | This token has no file.local. Mint it with file: { key, local: true } to let the person open their own file. |
| embed_file_busy | A file is already being opened in this editor. Wait for onFileOpened. |
| embed_session_expired | The session ended (10 hours, revoked, the document was deleted, or the frame was silent for 2 hours). Open the editor again with a new token. |
| embed_session_invalid | The session is not valid any more. Open the editor again with a new token. |
| embed_too_many_sessions | Too many sessions started for this app in a minute. Slow down, or ask for a higher limit. |
| embed_monthly_documents_reached | The app opened as many documents this month as its plan allows. Choose a bigger plan in the developer console, or wait for next month. |
| embed_monthly_sessions_reached | The app started as many sessions this month as its plan allows. Choose a bigger plan in the developer console, or wait for next month. |
| embed_version_purged | That saved version was deleted after the retention period (your server received it in its document.saved callback). Keep each saved file on your side. |
| embed_scope_denied | An embedded editor's session reaches only its own document's routes. |
| embed_download_not_allowed | The session's token has permissions.download: false: nothing is downloaded or exported. Mint the token without it to allow downloads. |
| embed_print_not_allowed | The session's token (or ui.features.print) turns printing off. |
| embed_copy_not_allowed | The session's token has permissions.copy: false: nothing is copied out of the editor (pasting in still works). |
| embed_export_format_not_allowed | permissions.export does not list this format. Add it to the list, or leave export out to allow every format. |
| embed_export_watermarked_pdf_only | The session's watermark is stamped into exports (watermark.inExports): only PDF exports and prints leave the editor. |
| embed_export_bytes_required | A watermarked export is handed over as bytes, never as a download link (the editor does this by itself; your own client must send delivery=bytes). |
| embed_watermark_failed | The watermark could not be stamped into this PDF, so it was not handed out. Try again; if it keeps failing, contact support with the file key. |
| embed_mode_read_only | The session's mode does not allow this (a comment, review or fillForms session inserts no files and changes no page structure). Mint an edit token for it. |
| embed_comment_not_allowed | The session may not comment (mode view or fillForms, or permissions.comment: false). |
| embed_invalid_mention | A mention names the people by their id (the ids onRequestUsers returned). |
| embed_invalid_events | webhook_events lists event types (or "*"); see Events and webhooks for the names. |
| embed_no_callback_url | Set a callback URL or a webhook URL for the app first. |
| embed_view_only | The session is view only (mode view, or comment/review/fillForms on a workbook, deck or PDF). Mint an edit token (mode: "edit") and call setMode("edit"). |
| embed_save_failed | The save did not finish. Edits are kept in the editor: call requestSave() again; if it keeps failing, see the console's events. |
| embed_save_timeout | The save took too long. Edits are kept; call requestSave() again. |
| embed_document_changed | The new token opened a different document than the one shown. |
| embed_destroyed | The editor was destroyed (destroy()). |
| embed_timeout | The editor did not answer in time. Check that the frame is still in the page. |
| embed_open_failed | open() could not start: see the message (no app ID, no such element, a non-https editor origin). |
| embed_file_mismatch | file.name passed to open() differs from the token's file.name (the token wins). |
| embed_mode_mismatch | mode passed to open() differs from the token's mode (the token wins). |
| embed_unsaved_edits | The editor still holds edits on their way to MR Office. Wait for onChange with dirty: false, then try again. |
| embed_command_unknown | This frame has no such Automation API method (or runs another apiVersion). Call getCapabilities() for what it runs. |
| embed_permission_denied | A plugin called a method its manifest does not grant (a write needs "write" in permissions). Add the permission to its mroffice-plugin.json and install it again. |
| embed_command_unsupported | The method is for another kind of file (word.* runs on .docx, excel.* on .xlsx, powerpoint.* on .pptx, pdf.* on .pdf). |
| embed_command_invalid | The method's params are missing or of the wrong type; details.fields names them. |
| embed_target_not_found | The text, range, bookmark, content control, slide or page the call names is not in the document. |
| embed_command_not_applicable | The command cannot apply there (a protected range, nothing matched, a setting this API does not write); details says why. |
| embed_editor_not_ready | The editor has not finished opening the document. Call it after onReady. |
| embed_read_only | The document is read only here (a protected or locked file, or one still being prepared). Nothing was changed. |
| embed_export_disabled | ui.features.export is false for this editor, so document.export is refused. |
| embed_command_failed | The editor could not finish the call; nothing was saved by it. Retry, and see the message. |
| embed_white_label_not_in_plan | ui.theme and ui.brandName apply on the Pro plan and above (or when MR Office has allowed them for your app); the editor shows MR Office's own look meanwhile. The developer console's Theme tab previews it on any plan. |
| embed_theme_adjusted | Part of ui.theme was changed to keep the editor readable (WCAG AA): an accent moved to the nearest lightness of its hue that passes, or a background the editor's text cannot be read on was not used. The message names which; the console's Theme tab shows the result. |
| embed_not_open | The editor is not open yet: wait for onReady (or await the handle's ready) before calling it. |

The developer console's Events view shows each app's last 50 events, newest first: sessions started and ended, the starts MR Office refused and why (a bad signature, an origin the app does not allow, an expired or replayed token), documents that failed to open, saves and their errors, and callbacks with your server's answers. Choose a session to see its own log.
