- Developer home
- Embed editors
- Conversion API
Conversion API
Conversion API
POST /api/v1/embed/convert writes a file in another format with MR Office's own readers and writers (the same import and File > Export the editors use, so a PDF looks as the editor prints it). Like ONLYOFFICE's ConvertService or Zoho's convert API: send a file by URL, upload or base64, name the output format, get a job with a download link.
curl https://mroffice.ai/api/v1/embed/convert \
-H "Authorization: Bearer $MROFFICE_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoice-1042-pdf" \
-d '{
"file": { "url": "https://files.example.com/signed/invoice-1042.docx" },
"output_format": "pdf"
}'{
"id": "6f1c…",
"object": "job",
"kind": "conversion",
"status": "succeeded",
"output_format": "pdf",
"inputs": [{ "name": "invoice-1042.docx", "format": "docx", "size": 48213, "sha256": "…" }],
"result": { "filename": "invoice-1042.pdf", "media_type": "application/pdf", "size": 91844, "sha256": "…", "page_count": 2 },
"error": null,
"download_url": "https://mroffice.ai/api/v1/embed/jobs/6f1c…/download?expires=…&signature=…",
"download_expires_at": "2026-11-21T10:00:00+00:00",
"expires_at": "2026-11-22T09:00:00+00:00"
}| From | To |
|---|---|
.docx, .docm, .dotx, .dotm, .doc, .dot, .rtf, .odt, .ott, .fodt, .sxw, .stw, .wps, .wpt, .mht, .mhtml, .html, .htm, .txt, .md, .xml, .epub, .fb2*, .pages*, .hwp, .hwpx | .docx, .docm, .dotx, .dotm, .pdf, .pdfa, .odt, .ott, .doc, .rtf, .epub, .fb2, .html, .txt, .md, .png, .jpg, .bmp, .gif, .tiff, .webp |
.xlsx, .xlsm, .xltx, .xltm, .xlsb, .xls, .xlt, .ods, .ots, .fods, .sxc, .et, .ett, .numbers, .csv, .tsv, .slk, .dif, .dbf, .wk1, .wks, .xml | .xlsx, .xlsm, .xltx, .xltm, .pdf, .pdfa, .ods, .ots, .fods, .xls, .csv, .tsv, .html, .png, .jpg, .bmp, .gif, .tiff, .webp |
.pptx, .pptm, .potx, .potm, .ppsx, .ppsm, .ppt, .pps, .pot, .odp, .otp, .fodp, .sxi, .dps, .dpt, .odg, .key* | .pptx, .pptm, .potx, .potm, .ppsx, .ppsm, .pdf, .pdfa, .odp, .otp, .ppt, .html, .txt, .png, .jpg, .bmp, .gif, .tiff, .webp |
.pdf, .xps*, .oxps*, .djvu* | .pdf, .pdfa, .txt, .md, .docx, .docm, .dotx, .dotm, .odt, .ott, .rtf, .doc, .epub, .fb2, .html, .xlsx, .pptx, .png, .jpg, .bmp, .gif, .tiff, .webp |
.vsdx*, .vsd*, .vssx*, .vstx*, .vsdm*, .vssm*, .vstm* | .pdf, .pdfa, .txt, .png, .jpg, .bmp, .gif, .tiff, .webp |
.png, .jpg, .gif, .bmp, .tiff, .webp | .pdf, .pdfa, .png, .jpg, .bmp, .gif, .tiff, .webp |
.mrink | .pdf, .pdfa, .docx, .png, .jpg, .bmp, .gif, .tiff, .webp |
- file is exactly one of url (a public https link MR Office fetches, private addresses refused), upload_id (POST /api/v1/embed/files, kept 24 hours) or data_base64; name (with its extension) or format says what it is.
- png and jpg are page images: options.pages ("1-3,5"), dpi (default 144, at most 300) or width in pixels, quality for jpg. One page is the picture itself; several, or options.zip, a ZIP of <name>-<page>.png.
- A writer that would lose part of the file (a generated PowerPoint package) refuses with embed_conversion_lossy and the loss codes; ask again with options.accept_losses to write it anyway. A document's tracked changes are accepted in PDF, HTML and text (options.revisions: "preserve" keeps them).
- The answer is a job: status succeeded with result (filename, media_type, size, sha256, page_count) and download_url, or failed with error { code, message }.
| Field | Meaning |
|---|---|
file | { url | upload_id | data_base64, name?, format? } |
output_format | One of the formats above (jpeg, markdown, htm, text are accepted aliases). |
options | pages, dpi, width, quality, zip (page images); accept_losses; revisions; pdfa (1b, 2b, 3b). |
async | true: answer 202 at once with the queued job (also Prefer: respond-async). |
webhook | true: tell the app's callback URL when the job ends. |
import { createClient } from "mroffice-embed/server";
const mro = createClient({ secretKey: process.env.MROFFICE_SECRET_KEY });
// Waits for the job (polling past the server's wait) and throws its error if it fails.
const job = await mro.convert({ file: { url: signedUrl, name: "q3.xlsx" }, outputFormat: "pdf" });
const pdf = await mro.download(job); // ArrayBuffer
// Page images: one PNG per page, as a ZIP
const pages = await mro.convert({
file: { data: await readFile("deck.pptx"), name: "deck.pptx" },
outputFormat: "png",
options: { pages: "1-3", dpi: 144, zip: true },
});import base64, os, time, requests
API = "https://mroffice.ai/api/v1/embed"
KEY = {"Authorization": f"Bearer {os.environ['MROFFICE_SECRET_KEY']}"}
with open("report.docx", "rb") as f:
body = {"file": {"data_base64": base64.b64encode(f.read()).decode(), "name": "report.docx"},
"output_format": "pdf", "async": True}
job = requests.post(f"{API}/convert", json=body, headers=KEY, timeout=60).json()
while job["status"] in ("queued", "running"):
time.sleep(2)
job = requests.get(f"{API}/jobs/{job['id']}", headers=KEY, timeout=30).json()
if job["status"] != "succeeded":
raise RuntimeError(job["error"])
pdf = requests.get(f"{API}/jobs/{job['id']}/content", headers=KEY, timeout=120).contentJobs: waiting, polling, webhooks, retries
- By default the request waits for its job up to 25 seconds and answers 200 with it; a longer job answers 202 with Location: /api/v1/embed/jobs/{id} and Retry-After: poll it until status is succeeded or failed.
- With webhook: true (or with the app subscribed to job.succeeded / job.failed, for every job) the app's webhook URL (its callback URL when it has none) receives job.succeeded or job.failed, signed with MRO-Signature like every event; body { id, type, job } with a fresh job.download_url.
- An Idempotency-Key header (1–128 characters) makes a retry safe: the same key answers the same job and is never counted twice.
- Outputs are kept 24 hours behind the secret key (…/content) and a signed link (download_url, valid an hour), then deleted; the inputs are deleted as soon as the job ends. DELETE /api/v1/embed/jobs/{id} deletes them now.
| Request | Does |
|---|---|
POST /api/v1/embed/convert | Converts a file. |
POST /api/v1/embed/templates/fill | Fills a template (one record, or a mail merge). |
POST /api/v1/embed/templates/inspect | Lists a template's tags (not counted). |
POST /api/v1/embed/compare | Compares two .docx versions. |
GET /api/v1/embed/jobs/{id} | A job's status and result. |
GET /api/v1/embed/jobs/{id}/content | A finished job's file (secret key). |
GET /api/v1/embed/jobs/{id}/download?expires=…&signature=… | The same file by its signed link (no key). |
GET /api/v1/embed/jobs[?kind=…&limit=…] | The app's recent jobs. |
DELETE /api/v1/embed/jobs/{id} | Deletes a finished job's files now. |
GET /api/v1/embed/formats | What converts to what (public). |
Limits and billing
Every request needs the app's secret key and reaches only that app's jobs and uploads. The Free plan runs 50 jobs a month (conversions, template fills and compares; a mail merge counts one per record), 10 a minute and 2 at once, then answers 429 (embed_monthly_conversions_reached, rate_limited, embed_jobs_busy). On a paid plan each job is billed as one session of the plan's included sessions and overage. A failed job is not counted. Files are held to the app's file size limit.