PaperType

API reference

One endpoint. JSON in, PDF out. Authenticate with Authorization: Bearer dp_…. Get a key, or see one rendered PDF first, no key needed. Task-shaped examples (Python, Node, GitHub Actions, n8n, Zapier, Google Sheets, invoices from JSON) are in the guides.

Install a client (optional)

Everything below is open source (MIT) on GitHub. The API works with plain HTTP too.

# Python SDK + CLI
pip install papertype
export PAPERTYPE_API_KEY=dp_...
papertype render README.md -o README.pdf

# MCP server for Claude Code, Claude Desktop, Cursor and other agents
claude mcp add papertype -e PAPERTYPE_API_KEY=dp_... -- npx -y papertype-mcp

Packages: papertype on PyPI · papertype-mcp on npm. Agent setup (Claude Desktop, Cursor, tool list): /for-agents. Plain-text index of this site for agents and AI crawlers: /llms.txt.

POST /v1/pdf

FieldTypeNotes
htmlstringHTML document or fragment. External URLs are never fetched; use data: URIs.
markdownstringMarkdown (tables, fenced code, footnotes, admonitions). Used when html is absent. Images at web URLs (README badges, ![…](https://…)) are never fetched and fail the render with 422 naming the URL; inline them as data:image/… URIs or remove them. Links are fine.
themestringclean (default), report, minimal, letter, or none for your own CSS only (HTML input; Markdown with none falls back to minimal).
cssstringExtra CSS appended after the theme. Supports @page rules.
page_sizestringA4, Letter, Legal, A5.
title, author, datestringUsed on the cover and in metadata.
cover, toc, page_numbersboolCover page; table of contents (Markdown only); page numbers (default true).
footer, headerstringPer-page footer text (bottom-left) and running header (top-right).
filenamestringContent-Disposition filename (default document.pdf).
templatestringHosted template name: invoice, certificate, report. Use with data instead of html/markdown. Fields and samples.
dataobjectJSON data for the template. Logos as data:image/… URIs.
outputstringpdf (default): the PDF is the response body. url: the response is JSON {url, filename, pages, bytes, expires_at}; the PDF is kept for 24 hours at a public, unguessable /v1/files/…pdf link and then deleted. For tools that attach files by URL (Zapier, chat messages, emails with links). The source is never stored.

Response

200 with application/pdf body (or JSON when output is url) and headers X-Pages, X-Quota-Used, X-Quota-Limit. Errors are JSON: 400 no source given, 401 bad key, 413 too large, 422 render or validation error (detail is a string for render errors, or a list of {loc, msg, type} for invalid fields), 429 quota reached.

Examples

# Python
import requests
r = requests.post("https://papertype.dev/v1/pdf", headers={"Authorization": "Bearer dp_..."},
    json={"html": "<h1>Receipt</h1><p>Thanks!</p>", "theme": "minimal", "page_size": "Letter"})
open("receipt.pdf", "wb").write(r.content)
// Node
const res = await fetch("https://papertype.dev/v1/pdf", { method: "POST",
  headers: { Authorization: "Bearer dp_...", "Content-Type": "application/json" },
  body: JSON.stringify({ markdown: "# Report\n\nHello", theme: "report", cover: true, toc: true }) });
require("fs").writeFileSync("report.pdf", Buffer.from(await res.arrayBuffer()));

GET /v1/me

Returns plan, quota and usage for the key. GET /v1 returns the same, so a tool whose "Test connection" button requests the base URL (Retool, for example) can verify the key: 200 with a valid key, 401 otherwise.

Limits and behaviour

OpenAPI: /v1/openapi.json