API reference
One endpoint turns HTML or a URL into a PDF or an image, rendered in a real, up-to-date browser. Send JSON or an HTML file, get the file back in the response body.
Quick start
Create a free account, copy your API key from the dashboard, and run:
curl https://api.printpipe.io/v1/generate \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "https://example.com", "format": "A4"}' \
--output document.pdfimport { writeFile } from 'node:fs/promises';
const res = await fetch('https://api.printpipe.io/v1/generate', {
method: 'POST',
headers: { 'X-API-Key': process.env.API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ html: '<h1>Invoice #42</h1>', format: 'A4', marginTop: 40 }),
});
if (!res.ok) throw new Error((await res.json()).message);
await writeFile('invoice.pdf', Buffer.from(await res.arrayBuffer()));import os, requests
res = requests.post(
"https://api.printpipe.io/v1/generate",
headers={"X-API-Key": os.environ["API_KEY"]},
json={"html": "<h1>Invoice #42</h1>", "format": "A4", "marginTop": 40},
timeout=60,
)
res.raise_for_status()
with open("invoice.pdf", "wb") as f:
f.write(res.content)<?php
$ch = curl_init('https://api.printpipe.io/v1/generate');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['html' => '<h1>Invoice #42</h1>', 'format' => 'A4']),
]);
$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
throw new RuntimeException(json_decode($pdf)->message);
}
file_put_contents('invoice.pdf', $pdf);using System.Net.Http.Json;
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("API_KEY"));
var res = await http.PostAsJsonAsync("https://api.printpipe.io/v1/generate",
new { html = "<h1>Invoice #42</h1>", format = "A4" });
res.EnsureSuccessStatusCode();
await File.WriteAllBytesAsync("invoice.pdf", await res.Content.ReadAsByteArrayAsync());body := strings.NewReader(`{"html": "<h1>Invoice #42</h1>", "format": "A4"}`)
req, _ := http.NewRequest("POST", "https://api.printpipe.io/v1/generate", body)
req.Header.Set("X-API-Key", os.Getenv("API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil { log.Fatal(err) }
defer res.Body.Close()
if res.StatusCode != 200 { log.Fatalf("conversion failed: %s", res.Status) }
out, _ := os.Create("invoice.pdf")
defer out.Close()
io.Copy(out, res.Body)require "net/http"
require "json"
uri = URI("https://api.printpipe.io/v1/generate")
req = Net::HTTP::Post.new(uri, "X-API-Key" => ENV["API_KEY"], "Content-Type" => "application/json")
req.body = { html: "<h1>Invoice #42</h1>", format: "A4" }.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
raise JSON.parse(res.body)["message"] unless res.is_a?(Net::HTTPSuccess)
File.binwrite("invoice.pdf", res.body)var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.printpipe.io/v1/generate"))
.header("X-API-Key", System.getenv("API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\"html\": \"<h1>Invoice #42</h1>\", \"format\": \"A4\"}"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofFile(Path.of("invoice.pdf")));
if (response.statusCode() != 200) throw new IllegalStateException("conversion failed");Authentication
Send your key in the X-API-Key header. Keys start with pp_ and are shown only once; rotate them in the dashboard if one leaks. Keys in the URL or request body are refused, because those end up in logs. The MCP server also accepts the key as Authorization: Bearer, which is what most MCP clients send.
Paid plans can have several keys (see plans), e.g. one per app or environment. Each key can get its own monthly credit limit, parallel limit and expiry date in the dashboard. All keys share your account’s credits and parallel conversions, which stay the overall limit. A key at its own credit limit gets 403 with errorCode 35, and an expired key gets 401; your other keys keep working.
Parameters
JSON body, Content-Type: application/json. Only html is required. Unknown parameters are rejected, so a typo never fails silently. null means “not set”.
Source
| Name | Type | Default | Description |
|---|---|---|---|
| htmlrequired | string | – | The HTML to convert, or a public URL (http or https) to open. Up to 5 MB; for larger pages pass a URL. Not needed with templateId. |
| templateId | string | – | Instead of html: the id of a template you saved in your dashboard (under Templates). It is filled in with data. |
| data | object | – | The values for templateId, as JSON. {{name}} in the template prints a value (HTML-escaped), {{#items}}…{{/items}} repeats for each item of a list. |
Output
| Name | Type | Default | Description |
|---|---|---|---|
| output | "pdf" | "png" | "jpeg" | "pdf" | What to produce: a PDF, or a screenshot of the page as PNG or JPEG. Screenshots cost credits like PDFs (1 per started MB). |
| filename | string | – | File name for the result (sent in Content-Disposition). ".pdf", ".png" or ".jpg" is added when missing. |
Page
| Name | Type | Default | Description |
|---|---|---|---|
| format | "Letter" | "Legal" | "Tabloid" | "Ledger" | "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "A4" | Paper size. Ignored when width and height are set, and for screenshots. |
| landscape | boolean | false | Landscape orientation. |
| width | integer (px) | – | Custom page width in CSS pixels (96 per inch). Use together with height. Screenshots: the browser window width (default 1280). |
| height | integer (px) | – | Custom page height in CSS pixels. Use together with width. Screenshots: the browser window height (default 800). |
| singlePage BasicPlusProEnterprise | boolean | false | Put the whole document on one page as tall as the content (up to 200 inches). Width comes from width or format; height is ignored. |
| marginTop | integer (px) | 0 | Top margin in CSS pixels. |
| marginRight | integer (px) | 0 | Right margin in CSS pixels. |
| marginBottom | integer (px) | 0 | Bottom margin in CSS pixels. |
| marginLeft | integer (px) | 0 | Left margin in CSS pixels. |
Rendering
| Name | Type | Default | Description |
|---|---|---|---|
| media | "screen" | "print" | "screen" | Which CSS media type to apply: screen styles (as in a browser window) or your @media print rules. |
| printBackground | boolean | true | Print background colours and images. |
| scale | number (0.1–2) | 1 | Zoom factor for the content. Screenshots: the pixel density, e.g. 2 for a sharp (retina) image twice the size. |
| waitFor | number (0–10 s; Free: 0–3 s) | 0 | Extra seconds to wait after the page loaded, for content added by JavaScript. |
| lazyLoad | boolean | false | Scroll through the page first so lazy-loaded images and content appear (stops after 12 s). |
Header & footer
| Name | Type | Default | Description |
|---|---|---|---|
| headerTemplate BasicPlusProEnterprise | string (HTML) | – | HTML printed at the top of every page. Elements with the classes pageNumber, totalPages, date, title and url are filled in. Needs a top margin to be visible. |
| footerTemplate BasicPlusProEnterprise | string (HTML) | – | Like headerTemplate, at the bottom of every page. Needs a bottom margin. |
Screenshot
| Name | Type | Default | Description |
|---|---|---|---|
| fullPage | boolean | – | Screenshots only. Capture the whole page (default), or false for just the browser window. Pages are cut off at 16384 device pixels. |
| quality | integer (1–100) | – | JPEG screenshots only. Image quality; higher is sharper and larger. Default 80. |
Security
| Name | Type | Default | Description |
|---|---|---|---|
| userPassword BasicPlusProEnterprise | string | – | Password needed to open the PDF. Setting it (or ownerPassword) encrypts the file with AES-256. |
| ownerPassword BasicPlusProEnterprise | string | – | Password that lifts the permission restrictions. Random when you set only userPassword. |
| permissions BasicPlusProEnterprise | array of "print", "modify", "copy", "edit", "fillform", "extract", "assemble", "printbest" | ["print"] | What readers may do with an encrypted PDF without the owner password. |
Async
| Name | Type | Default | Description |
|---|---|---|---|
| callBackUrl | string (URL) | – | Plus, Pro and Enterprise plans. Convert in the background: the API answers 202 at once and POSTs {"document": base64 file, "state": …, "contentType": "application/pdf"} to this public URL when done. |
| state | string | – | Any text (up to 1 KB) returned unchanged in the callback, e.g. your order id or a secret to verify the callback. |
Responses
- 200: the file itself (
application/pdf, orimage/png/image/jpegfor screenshots). Write the body to a file; don't parse it as JSON. Headers:X-Credits-Charged,X-Credits-RemainingandContent-Disposition(with your filename). - 202: accepted for background conversion (requests with callBackUrl).
- 4xx / 5xx: JSON with an error code and a readable message, see below.
Errors
HTTP/1.1 400 Bad Request
Content-Type: application/json
{ "errorCode": 11, "message": "scale: Too big: expected number to be <=2" }| HTTP | errorCode | When |
|---|---|---|
| 400 | 10 | The body is not a JSON object, HTML file or multipart form, or the request is malformed. An unsupported Content-Type gets 415 with this code. |
| 400 | 11 | A parameter is unknown or invalid. The message names it. |
| 400 | 12 | The page could not be rendered: unreachable or blocked URL, DNS error, TLS error or timeout. |
| 404 | 13 | There is no template with this templateId in your account. |
| 400 | 14 | The template could not be filled in: a syntax error, or the result is larger than 5 MB. The message says where. |
| 401 | 20 | The X-API-Key header is missing, or the key is invalid, revoked or past its expiry date. |
| 403 | 30 | All credits of your billing month are used. They reset on your monthly billing date. |
| 403 | 31 | The PDF or image is larger than your plan allows (5 MB on Free). |
| 429 | 32 | Too many conversions at the same time for your plan, or for this key’s own parallel limit. Retry shortly. |
| 429 | 33 | Too many requests: the Free plan’s daily limit, or the online converter’s hourly limit. |
| 403 | 34 | Your plan doesn’t include this feature, e.g. callBackUrl (Plus, Pro and Enterprise) or passwords and header/footer templates (Basic, Plus, Pro and Enterprise). |
| 403 | 35 | This API key’s own monthly credit limit is used (set in your dashboard). Your other keys keep working. |
| 500 | 50 | Something broke on our side. Retry with backoff. |
| 503 | 51 | All renderers are busy. Retry with backoff. |
Retry 429, 500 and 503 with exponential backoff. Don't retry other 4xx errors unchanged; they will fail again.
Sending an HTML file
Instead of JSON, you can send an HTML file as it is: as the request body with Content-Type: text/html and the options in the query string, or as a multipart form with the file in the file field and the options as other fields. Every option works as in JSON: write booleans as true or false, and lists like permissions comma-separated. The same 5 MB limit applies.
curl "https://api.printpipe.io/v1/generate?format=A4&marginTop=40&filename=report" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: text/html" \
--data-binary @report.html \
--output report.pdfcurl https://api.printpipe.io/v1/generate \
-H "X-API-Key: $API_KEY" \
-F "[email protected]" \
-F "format=A4" \
-F "permissions=print,copy" \
--output report.pdfRelative links in the file (<img src="logo.png">) can't load, because the page has no address of its own. Use absolute URLs, or embed images and fonts as data: URIs.
Templates
Save your HTML once in the dashboard (under Templates), then send only templateId and the data for each document, instead of html. All other options (paper size, margins, passwords, screenshots, callbacks) work as usual. Every plan includes templates, from 3 on Free to 500 on Enterprise.
curl https://api.printpipe.io/v1/generate \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{
"templateId": "0199a0c2-3f4e-7b6a-9c1d-2e5f8a7b4c3d",
"data": {
"number": "2026-042",
"customer": { "name": "Acme Ltd" },
"items": [
{ "name": "Consulting", "qty": 3, "price": "€300.00" },
{ "name": "Support plan", "qty": 1, "price": "€90.00" }
],
"paid": true
}
}' --output invoice.pdfTemplates use Mustache syntax:
<h1>Invoice {{number}}</h1>
<p>{{customer.name}}</p>
<table>
{{#items}}
<tr><td>{{name}}</td><td>{{qty}}</td><td>{{price}}</td></tr>
{{/items}}
</table>
{{#paid}}<p>Paid, thank you!</p>{{/paid}}
{{^paid}}<p>Please pay within 14 days.</p>{{/paid}}{{name}}prints a value, HTML-escaped;{{{name}}}prints it unescaped, for HTML you trust. Nested values use dots:{{customer.name}}.{{#items}}…{{/items}}repeats for each item of a list ({{.}}is the item itself), shows once for an object ortrue, and is left out when the value is missing, false or empty.{{^items}}…{{/items}}is the opposite.- Format numbers, prices and dates in your data; templates contain no code.
- Templates are up to 512 KB (load images from a URL), and a filled-in template up to 5 MB. An unknown id fails with error code 13, a template that can't be filled in with 14.
- Templates are stored until you delete them. The data you send and the documents you get are never stored.
Screenshots
Set output to "png" or "jpeg" to get an image of the page instead of a PDF, on every plan. Images cost credits like PDFs: 1 per started MB.
{
"html": "https://example.com",
"output": "png",
"width": 1440,
"fullPage": true,
"scale": 2
}widthandheightset the browser window (default 1280 × 800).fullPage(default true) captures the whole page; false captures only the window.scaleis the pixel density: 2 gives a sharp image twice the size, like on a retina screen.quality(1–100) applies to JPEG.- PDF-only options (margins, landscape, headers and footers, passwords, singlePage) are refused with screenshots, so mistakes don't go unnoticed. Free plan images carry the same small watermark as PDFs.
Async & callbacks
PlusProEnterpriseAdd callBackUrl to convert in the background. The API answers 202 immediately and POSTs the result to your URL when it's ready:
curl https://api.printpipe.io/v1/generate \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{"html": "https://example.com", "callBackUrl": "https://your-app.example/pdf-ready", "state": "order-42-7f3c9a"}'
# HTTP/1.1 202 Accepted
# {"status": "accepted"}POST https://your-app.example/pdf-ready
Content-Type: application/json
X-Webhook-Signature: t=1795200000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
{
"document": "JVBERi0xLjcKJeLjz9MK...", // the PDF (or image), base64
"state": "order-42-7f3c9a",
"contentType": "application/pdf"
}- Any HTTP response from your endpoint counts as delivered. An unreachable endpoint is retried twice (after 10 s and 60 s).
- No callback is sent when the conversion fails, so put a timeout on your side.
- Every callback is signed.
X-Webhook-Signatureholds a timestamp and an HMAC-SHA256 of<timestamp>.<raw body>, made with the callback signing secret of the API key that made the request (in your dashboard, under each key; every key has its own, and rotating a key keeps it). Check it, and reject timestamps older than a few minutes (example below). - The URL must be publicly reachable; private and internal addresses are refused.
import { createHmac, timingSafeEqual } from 'node:crypto';
// rawBody: the request body exactly as received (a string, before JSON.parse).
function isGenuineCallback(rawBody, signatureHeader, secret) {
const { t, v1 } = Object.fromEntries(signatureHeader.split(',').map((p) => p.split('=')));
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false; // older than 5 minutes
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
return v1.length === expected.length && timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
}MCP server
PlusProEnterpriseConnect AI assistants and agents (Claude, Cursor, VS Code and any client that speaks the Model Context Protocol) and let them create PDFs for you. It uses your API key, your credits and the same options as the REST API.
URL
https://api.printpipe.io/mcp
Transport
Streamable HTTP
Auth
Authorization: Bearer <key>
Connect your client
claude mcp add --transport http printpipe.io https://api.printpipe.io/mcp \
--header "Authorization: Bearer YOUR_API_KEY"// claude_desktop_config.json (Settings → Developer → Edit config)
{
"mcpServers": {
"printpipe.io": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://api.printpipe.io/mcp", "--header", "Authorization:${AUTH}"],
"env": { "AUTH": "Bearer YOUR_API_KEY" }
}
}
}// ~/.cursor/mcp.json
{
"mcpServers": {
"printpipe.io": {
"url": "https://api.printpipe.io/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
}
}// .vscode/mcp.json: VS Code asks for the key once and stores it securely
{
"servers": {
"printpipe.io": {
"type": "http",
"url": "https://api.printpipe.io/mcp",
"headers": { "Authorization": "Bearer ${input:printpipe.io-key}" }
}
},
"inputs": [
{ "type": "promptString", "id": "printpipe.io-key", "description": "printpipe.io API key", "password": true }
]
}curl https://api.printpipe.io/mcp \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"generate_pdf","arguments":{"html":"<h1>Hello</h1>"}}}'The key goes in a header, never in the URL, so it doesn’t end up in logs or browser history. Treat config files with your key like passwords.
Tools
| generate_pdf | Converts HTML or a public URL to a PDF and returns the file. Takes the same parameters as the REST API, except callBackUrl and state. |
| get_usage | Returns the plan, the credits used and left this billing month, when they reset, and the plan limits. |
Try asking
- “Turn this invoice HTML into an A4 PDF with 20px margins and page numbers in the footer.”
- “Save https://example.com as a landscape PDF with background graphics.”
- “How many PDF credits do I have left this month?”
- PDFs come back inside the response, up to 10 MB. For larger documents use the REST API; nothing is charged when a PDF is too large to return.
- Credits, parallel limits and the privacy rules are exactly those of the REST API: nothing is stored.
- Each request stands alone: there are no sessions or streams to keep open.
Encryption
BasicPlusProEnterpriseSetting userPassword or ownerPassword encrypts the PDF with AES-256. Without the owner password, readers may only do what permissions allows (default: print).
{
"html": "<h1>Payslip</h1>",
"userPassword": "opens-the-file",
"ownerPassword": "lifts-restrictions",
"permissions": ["print"]
}Plans & limits
| Plan | Credits / month | Parallel | Max PDF | Per day | API keys | All options | No watermark | Async | MCP |
|---|---|---|---|---|---|---|---|---|---|
| Free | 100 | 1 | 5 MB | 20 | 1 | – | – | – | – |
| Basic | 1,000 | 3 | 100 MB | No limit | 3 | ✓ | ✓ | – | – |
| Plus | 5,000 | 10 | 100 MB | No limit | 5 | ✓ | ✓ | ✓ | ✓ |
| Pro | 10,000 | 20 | 100 MB | No limit | 10 | ✓ | ✓ | ✓ | ✓ |
| Enterprise 25K | 25,000 | 25 | 100 MB | No limit | 25 | ✓ | ✓ | ✓ | ✓ |
| Enterprise 50K | 50,000 | 50 | 100 MB | No limit | 25 | ✓ | ✓ | ✓ | ✓ |
| Enterprise 75K | 75,000 | 75 | 100 MB | No limit | 25 | ✓ | ✓ | ✓ | ✓ |
| Enterprise 100K | 100,000 | 100 | 100 MB | No limit | 25 | ✓ | ✓ | ✓ | ✓ |
- Each PDF costs 1 credit per started 1 MB: up to 1 MB is 1 credit, a 5.4 MB PDF is 6 credits. Failed conversions are free.
- Credits reset every month on your billing date: the day you subscribed or last changed plan (on Free, the day you signed up). Your dashboard and the
get_usageMCP tool show the exact time. - Each plan limits how many conversions run at the same time; extra requests get 429. There is no per-minute limit: to send many PDFs, run one worker per parallel conversion and queue the rest.
- Free plan PDFs can be up to 5 MB; paid plans up to 100 MB (the limit for any plan).
- The Free plan is for trying the API: every page gets a small “Made with printpipe.io” line at the bottom, options tagged with plans above are refused (403, error 34),
waitForis at most 3 s, a conversion stops after 15 s, and there are at most 20 conversions per 24 hours (429, error 33). Paid plans have none of these limits. - Request body: up to 5 MB. For bigger pages, pass a URL.
- On paid plans a conversion stops after 30 s and
waitForis at most 10 s (Free: 15 s and 3 s).
Print CSS tips
A starting point for documents that paginate cleanly. Send it with "media": "print":
@page { size: A4; margin: 16mm 14mm; }
/* Keep colours and backgrounds exactly as designed. */
html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Start each chapter on a new page; never split these blocks. */
.chapter { break-before: page; }
figure, tr, .card { break-inside: avoid; }
/* Keep headings with the paragraph that follows. */
h1, h2, h3 { break-after: avoid; }
/* Repeat table headers on every page. */
thead { display: table-header-group; }
/* Fewer orphaned lines at page ends. */
p { orphans: 3; widows: 3; }- Use
@pageand@media printCSS with"media": "print"for print-specific layouts. - Control page breaks with
break-before,break-afterandbreak-inside: avoid. - Web fonts (Google Fonts or
@font-face) work; they are loaded before printing. - Content drawn by JavaScript after load needs
waitFor; images that load on scroll needlazyLoad. - Pages can only reach the public internet: local, private and cloud-internal addresses are blocked.
- With
singlePage(Basic, Plus, Pro and Enterprise), very tall pages are capped at 200 inches, the largest page Acrobat opens.
Troubleshooting
The PDF is blank or missing content
Content drawn by JavaScript after the page loads needs "waitFor" (seconds). Pages that load images on scroll need "lazyLoad": true. Check that the URL is public: sign-in pages and private addresses can’t be reached.
Images or fonts are missing
Relative URLs have no base when you send HTML: use absolute https URLs or data: URIs. Fonts from Google Fonts and @font-face load before printing.
The layout looks different from the browser
Without "media": "print" the page renders with screen styles. Set a paper size that matches your design, and use "printBackground": true to keep background colours.
Tables or cards are cut between pages
Add break-inside: avoid to rows and cards, and display: table-header-group to thead so headers repeat. See the print CSS above.
I get 429 errors
errorCode 32: your plan’s parallel conversions are all busy; queue requests on your side (one worker per parallel slot) or upgrade for more. errorCode 33: the Free plan’s 20 conversions per day are used up; the message says when they free up.
My MCP client can’t connect
Check that the URL ends in /mcp, the key is sent as "Authorization: Bearer <key>" and your plan includes MCP (Plus, Pro and Enterprise; other plans get 403). Clients that only start local commands, like Claude Desktop’s config file, need the mcp-remote bridge shown above.
Still stuck? Email us; priority support comes with Pro and Enterprise.
Privacy
Your HTML, the URLs and data you send, the files we produce and your callback URLs are never stored or logged. We keep only what billing and your history need: when a conversion ran, whether it succeeded, its size, credits and duration, and which key and template it used. Templates you save are kept until you delete them. Privacy policy