- Developer home
- Embed editors
- Session tokens
Session tokens
This page is not yet translated into your language; it is shown in English.
Session tokens
A session token is a JWT signed HS256 with your app's secret key. It is the only thing that decides which file opens, for whom, and whether they can edit: nothing the page says can change it. Mint one per person per page load.
| Claim | Value |
|---|---|
iss | Your app ID. |
aud | "mroffice-embed" |
iat, exp | Issued and expires, in seconds. exp − iat is at most 3600; 600 is a good value. The token only starts the session. |
jti | Unique per token. A token starts one session, once; a replay is refused. |
file.key | Your stable id for the file (1–128 of A–Z a–z 0–9 . _ = -). Everyone given the same key edits the same document together. |
file.name | The file name with its extension: .docx, .xlsx, .pptx, .pdf, or one of the other formats in Supported formats (.doc, .rtf, .odt, .csv, .xls, .ppt…), a code file (.py, .ts, .json…) or a handwriting document (.mrink): see Code and handwriting. |
file.url | file.upload_id | Where MR Office reads the file: a public https URL (a signed link to your storage is ideal), or the id of an upload (see Opening files). One of the two. |
file.version | Optional: your version of the file (an ETag). See Versions and conflicts. |
mode | "edit" (default), "view", "comment", "review" or "fillForms" (see Permissions and modes). |
permissions | Optional: download, print, copy, export, acceptRejectChanges, comment, manageComments (see Permissions and modes). |
watermark | Optional: { text, opacity?, angle?, fontSize?, color?, inExports? } (see Watermark). |
file.new | Optional: true opens a blank document of the format file.name says (.docx, .xlsx, .pptx, .mrink or a code file such as .py) instead of reading a file: no url or upload_id. It is made the first time the key is used (later tokens join it), and its first save is sent to you as version 1. |
features | Optional: { run: true } lets the Code editor run the file (Run, Debug, tests, console): only for an app on Pro or above, each run counted as one server job. Off by default (see Code and handwriting). |
user.id, user.name | Your id for the person (never shown) and the name the other editors see. |
user.email, user.avatarUrl, user.color | Optional: the email a watermark or a mention may name (never shown to the others), an https picture and a #RRGGBB colour for their cursor and presence. |
user.roles | Optional: who the person is on a PDF form whose fields are assigned to roles (ONLYOFFICE's user.roles). In fillForms they fill the fields of their first role and the fields given to no role. |
Once started, a session lasts 10 hours (as Microsoft recommends for WOPI access tokens) unless revoked. About five minutes before it ends the SDK calls your refreshToken() and continues in a new session on the same document, without reloading the editor. Rotating your secret key keeps the old key working for 24 hours (or revokes it at once if you choose); tokens may name the key they were signed with in the JWT header's kid.
Prefer not to sign JWTs yourself? POST /api/v1/embed/sessions with your secret key returns the same token: { "file": {…}, "mode": "edit", "user": {…}, "permissions": {…}, "watermark": {…}, "ttl_seconds": 600 }.