POST /format/v1/document
Convert Markdown, JSON, or plain text into professionally formatted documents with full control over typography and layout.
Request
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Source content to format |
input_format | string | No | Input format: md, json, or text. Default: md |
output_format | string | Yes | Output format: pdf, docx, or html_preview |
options | object | No | Formatting configuration (see below) |
Options
Layout and branding
| Option | Type | Description |
|---|---|---|
template | string | standard (default) or pleading (legal paper with line numbers) |
header | string | Text for document header |
footer | string | Text for document footer (supports {{page}} for page numbers) |
margins | object | { top, right, bottom, left } in points |
images | array | Image objects: { url, width, height, align, x, y } |
Element styles
Thestyles object lets you define the appearance of each element type:
| Property | Type | Description |
|---|---|---|
font | string | Font family: Times New Roman, Arial, Georgia, Courier New |
size | number | Font size in points |
bold | boolean | Bold text |
alignment | string | left, center, right, or justify |
spacingBefore | number | Space before element in points |
spacingAfter | number | Space after element in points |
Template components with variables
Use{{variable}} placeholders in your content, then provide values:
Response
For pdf and docx
Returns binary file content with appropriate headers:
- Content-Type:
application/pdforapplication/vnd.openxmlformats-officedocument.wordprocessingml.document - Content-Disposition:
attachment; filename="formatted.pdf"orformatted.docx
For html_preview
Returns HTML string:
Examples
Court pleading with line numbers
Contract with dynamic values
Quick preview
Error codes
| Status | Description |
|---|---|
400 | Invalid input format, missing required fields, or template variable errors |
401 | Invalid or missing API key |
404 | Referenced template not found |