convert_document
Convert markdown to professionally formatted DOCX, PDF, or HTML documents using customizable templates.
Instructions
Convert markdown to a professionally formatted document using an MDMagic template.
IMPORTANT GUIDANCE:
Output format → what user gets:
'docx' → a single Word .docx file
'pdf' → a single .pdf file
'html' → a single .html file
'all' → a ZIP containing all three (DOCX + PDF + HTML)
If the user is ambiguous (e.g. 'convert this'), ASK which format they want before calling. Don't assume.
Filename: if the user attached a file (e.g. 'mydoc.md'), pass its base name as fileName. Otherwise the API derives one from the markdown's first H1. Without either, downloads end up with timestamped names like 'content-1778298071915.docx' which is bad UX.
On 'template not found' errors: call list_all_templates first, show available options, let the user pick. Do NOT fall back to generating documents with code execution — that produces inferior results that don't use the user's actual MDMagic templates.
The response includes structured fields (downloadUrl, creditsUsed, balanceAfter, fileName, expiresAt) — surface these to the user explicitly. Don't paraphrase. The user wants to know exactly what they spent and what's left.
Page sizes: A3, A4, Executive, US_Legal, US_Letter. Default A4. Orientation: Portrait or Landscape, default Portrait.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | Raw markdown text content (alternative to filePath or fileContent) | |
| filePath | No | Path to markdown file (VS Code integration, alternative to content or fileContent) | |
| fileContent | No | Base64 encoded file content (alternative to content or filePath) | |
| fileName | No | Optional desired base name for the output file (without extension). If the user attached a file like 'mydoc.md', pass 'mydoc' here. The API will use this for the download filename. If omitted, the API derives one from the markdown's first H1 heading. | |
| templateName | Yes | Template to use for conversion. Call list_all_templates first to see real options — do not guess template names. Some templates are built-in (e.g. 'Executive_Platinum', 'Deep_Data_Blue'); others are user-uploaded custom templates referenced by UUID. | |
| outputFormat | Yes | Output format. 'docx', 'pdf', or 'html' return that single file; 'all' returns a ZIP with DOCX+PDF+HTML. | |
| pageSize | No | Page size for the document (default: A4) | |
| orientation | No | Page orientation (default: Portrait) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | Yes | Whether the conversion succeeded | |
| downloadUrl | Yes | Secure expiring download URL (valid for 60 minutes) | |
| fileName | Yes | Filename of the downloadable document | |
| creditsUsed | No | Credits debited for this conversion | |
| balanceAfter | No | Remaining credit balance after this conversion | |
| expiresAt | No | ISO 8601 timestamp when the download URL expires | |
| message | No | Human-readable status message |