---
title: "Convert Markdown to a styled PDF"
method: POST
path: "/markdown-to-pdf"
tags: ["Documents"]
---

# Convert Markdown to a styled PDF

`POST /markdown-to-pdf`

## Request

- Base URL: `https://api.cofferdock.com`
- URL: `https://api.cofferdock.com/markdown-to-pdf`
- Auth: API key in header `x-api-key`

Converts Markdown straight to a PDF (Markdown to HTML, then the same headless-browser rendering as /pdf), with a clean default typography built in.

Costs 1 credit per call.

## Request body

- object
  - `markdown` string, required: The Markdown text to turn into a PDF (CommonMark plus GitHub-style tables and strikethrough), up to 2 MB.
  - `format` 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'Tabloid': Paper size: "A4" (default), "A3", "A5", "Letter", "Legal" or "Tabloid".
  - `landscape` boolean: true = landscape page, false (default) = portrait.
  - `print_background` boolean: true (default) = print background colors and images, including the grey shading behind code; false = leave them out.
  - `scale` number: Content scale factor (0.1-2). Default 1; use a value below 1 to fit more on each page.
  - `margin` integer: Millimeters, same on all 4 sides.
  - `output` 'json' | 'pdf' | 'url': How to return the PDF: "json" (base64 in the JSON response), "pdf" (the PDF itself, ready for n8n/Make/Zapier) or "url" (a temporary download link, valid 15 minutes). Default: json when the request is JSON, pdf when the Markdown was sent as raw text.

## Response `200`

Result.

- object
  - `success` boolean
  - `pdf` string, byte
  - `mime_type` string
  - `meta` object
    - `format` string
    - `size_bytes` integer
    - `used` integer: Credits used this month, after this call.
    - `remaining` integer, nullable: Credits left this month (null = unlimited).
    - `unlimited` boolean

## Other responses

- `400`: Invalid input (nothing is charged).
- `401`: Missing or invalid API key.
- `403`: Email not verified.
- `422`: An image, font or stylesheet linked from the HTML did not finish loading within 20 seconds. The body says which sites (`hosts`). The credit is not charged.
- `429`: Monthly credit limit reached, or too many requests per minute for this key (see Retry-After).
- `503`: Server busy (queue full). Retry after the seconds in the Retry-After header.

---

[API](https://skmtc.dev/cofferdock/apis/cofferdock-api.md) · [All operations](https://skmtc.dev/cofferdock/apis/cofferdock-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cofferdock/apis/cofferdock-api/revisions/b57aa000d33a?raw)
