---
title: "Format documents with professional layouts"
method: POST
path: "/format/v1/document"
tags: ["Format"]
---

# Format documents with professional layouts

`POST /format/v1/document`

Convert Markdown, JSON, or text content to professionally formatted PDF, DOCX, or HTML documents. Supports template components with variable interpolation for creating consistent legal documents like contracts, briefs, and reports.

## Request body

- object
  - `content` string, required — The source content to format
  - `input_format` 'md' | 'json' | 'text' — Format of the input content
  - `output_format` 'pdf' | 'docx' | 'html_preview', required — Desired output format
  - `options` object — Optional template composition and styling settings used during document generation
    - `components` object[] — Template components with variables
      - `templateId` string — ID of saved template component
      - `content` string — Inline template content
      - `variables` object — Variables for template interpolation
      - `styles` object — Custom styling options

## Response `200`

Formatted document (binary for PDF/DOCX, HTML for preview)

## Other responses

- `400` — Invalid input format, missing required fields, or template variable errors
- `401` — Invalid or missing API key
- `404` — Template component not found

---

[API](https://skmtc.net/casemark/apis/case-dev-api.md) · [All operations](https://skmtc.net/casemark/apis/case-dev-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/casemark/case-dev-api/revisions/5b7e64e6d6f9/schema)
