← MD to PDF

API documentation

Markdown to PDF over HTTP, powered by pandoc and WeasyPrint. Mermaid diagrams render through headless Chromium and math renders through KaTeX — both automatically, with no flags to set.

Base URL

https://md2pdf-api-service-git-501785607868.europe-west1.run.app

Every request needs an x-api-key header. Keys are free and issued instantly from an email address on the landing page.

POST /convert

Convert Markdown to PDF.

Method and pathPOST /convert
Authx-api-key: YOUR_KEY header, required
Request bodyRaw UTF-8 Markdown — not JSON, not multipart
Content-TypeAny; the body is read as raw bytes
Success200, Content-Type: application/pdf
Rate limit5 requests/minute per key (sliding window)
Max input size10 MB
Render timeout60 s per request

Query parameters

mermaid_max_height — optional. Caps Mermaid diagram height. A bare number means millimetres (180 becomes 180mm); a CSS unit such as 60vh passes through unchanged. Defaults to 70vh.

Error responses

Failures return a JSON body of the form {"detail": "..."}.

StatusWhen
401Missing or unknown x-api-key
429Rate limit exceeded — the Retry-After header gives the seconds until the window frees up
400Empty body, or the body is not valid UTF-8
413Markdown exceeds the 10 MB size limit
422pandoc/render failed, or the render timed out

GET /health

Liveness check. Returns 200 with {"status": "ok"}.

Examples

curl

curl -X POST "https://md2pdf-api-service-git-501785607868.europe-west1.run.app/convert" \
  -H "x-api-key: YOUR_API_KEY" \
  --data-binary @doc.md -o doc.pdf

Python

import requests

with open("doc.md", "rb") as f:
    md = f.read()

r = requests.post("https://md2pdf-api-service-git-501785607868.europe-west1.run.app/convert",
    headers={"x-api-key": "YOUR_API_KEY"},
    data=md, timeout=120)
open("doc.pdf", "wb").write(r.content)

TypeScript

const md: string = await (await fetch("/doc.md")).text();

const res = await fetch("https://md2pdf-api-service-git-501785607868.europe-west1.run.app/convert", {
  method: "POST",
  headers: { "x-api-key": "YOUR_API_KEY" },
  body: md,
});
const pdf: Blob = await res.blob(); // application/pdf

JavaScript

const md = await (await fetch("/doc.md")).text();

const res = await fetch("https://md2pdf-api-service-git-501785607868.europe-west1.run.app/convert", {
  method: "POST",
  headers: { "x-api-key": "YOUR_API_KEY" },
  body: md,
});
const pdf = await res.blob(); // application/pdf

Notes and gotchas