export_document
Round-trips the document through the original docx renderer, preserving tables, borders, shading, alternating row colors, headers, footers, fonts, inline styling, and embedded images. Two modes: pass html directly to export ad-hoc content, OR pass session_id to export the session's current state. Format options: 'docx' (default, native Open XML, best for programmatic processing or mail merge), 'pdf', 'html', 'markdown', or 'txt' ('doc' is a legacy Word-compatible HTML alias). Fidelity is the differentiator vs naive HTML to docx converters. When called as an MCP tool, binary formats (docx/pdf/doc) are returned as a short-lived signed download_url in a JSON envelope (fetch it to get the file); text formats (html/markdown/txt) are returned inline.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| html | No | HTML content to export inline. Used instead of the session document if provided. | |
| format | No | Export format. One of docx (default), pdf, html, markdown, txt. | docx |
| options | No | Customization (paper, margins, filename, watermark, etc.). | |
| filename | No | DEPRECATED. Use options.filename. Top-level kept for legacy callers. | |
| upload_id | No | ID returned by /v1/uploads (large-document upload flow, for payloads above ~25 MB). When set, the route fetches the HTML body from the uploaded payload instead of using the html field. | |
| session_id | No | Session ID to export from (the document is taken from the session). Required if html is omitted. | |
| authorization | No | ||
| source_filename | No | The document's original/source filename (e.g. the name it was uploaded under). Used as the default export filename when no explicit options.filename is set, taking precedence over the first heading. |