API referencePDF
Generate paper-perfect PDFs from any URL or HTML string. Full control over page size, margins, scale, page ranges, and running headers/footers — with real @media print support. Costs 2 credits.
Endpoint
POST
https://api.renderkit.tech/v1/pdfPDF parameters
| Parameter | Type | Description |
|---|---|---|
page_formatstring | string | Standard paper size. Options: A4, A3, A5, Letter, Legal, Tabloid. Defaults to A4. |
landscapeboolean | boolean | Rotate the page to landscape orientation. Defaults to false. |
print_backgroundboolean | boolean | Render background colors and images. Defaults to true. |
scalenumber | number | Scale the rendered content (0.1–2). Defaults to 1. |
marginstring | string | Uniform margin for all sides, e.g. "16mm" or "1in". |
margin_topstring | string | Top margin (overrides margin). |
margin_rightstring | string | Right margin (overrides margin). |
margin_bottomstring | string | Bottom margin (overrides margin). |
margin_leftstring | string | Left margin (overrides margin). |
page_rangestring | string | Subset of pages to emit, e.g. "1-3, 5". |
page_widthstring | string | Custom page width (overrides page_format), e.g. "210mm". |
page_heightstring | string | Custom page height (overrides page_format). |
prefer_css_page_sizeboolean | boolean | Honor the page's own @page size declaration. Defaults to false. |
header_htmlstring | string | HTML for a running page header (max 50 KB). Supports print tokens like page number. |
footer_htmlstring | string | HTML for a running page footer (max 50 KB). |
Common parameters
| Parameter | Type | Description |
|---|---|---|
urlstring | string | Fully-qualified URL to render. Max 4096 chars. Provide this or html, not both. |
htmlstring | string | Raw HTML to render instead of fetching a URL. Up to 2 MB. Provide this or url. |
wait_untilstring | string | Navigation lifecycle event to wait for before rendering. Options: load, domcontentloaded, networkidle. Defaults to networkidle. |
delayinteger | integer | Extra wait after the page is ready, in milliseconds (0–10000). Defaults to 0. |
timeoutinteger | integer | Hard navigation timeout in milliseconds (5000–60000). Clamped to your plan's maximum. Defaults to 30000. |
wait_for_selectorstring | string | Block until this CSS selector appears in the DOM. |
user_agentstring | string | Override the browser User-Agent string. |
countrygrowth+string | string | Render from a US or GB IP so geo-restricted and region-walled pages load correctly. Options: us, gb. |
cookieshobby+array | array | Cookies to set before navigation. Up to 50 entries. |
headershobby+object | object | Extra HTTP request headers, e.g. an Authorization header for gated pages. |
inject_csshobby+string | string | CSS injected into the page before rendering (max 100 KB). |
inject_jsgrowth+string | string | JavaScript executed in the page before rendering (max 100 KB). |
cacheboolean | boolean | Serve an identical prior render from cache when available. Cache hits are free. Defaults to true. |
cache_ttlinteger | integer | Cache lifetime in seconds (0–2592000, i.e. up to 30 days). Defaults to 3600. |
cache_keystring | string | Override the automatic cache key to force-share or force-separate renders. |
asynchobby+boolean | boolean | Queue the render and return a job immediately instead of blocking. See Webhooks & async. Defaults to false. |
webhook_urlhobby+string | string | HTTPS URL that receives a signed render.done / render.failed callback when an async render finishes. |
webhook_secrethobby+string | string | Secret used to HMAC-sign the webhook payload (X-RenderKit-Signature). |
Request
curl https://api.renderkit.tech/v1/pdf \
-H "x-api-key: $RK_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/report",
"page_format": "A4",
"print_background": true,
"margin": "16mm"
}'Response
200 · application/json
{
"success": true,
"data": {
"id": "rnd_2pq9x7b1",
"type": "pdf",
"status": "done",
"url": "https://cdn.renderkit.tech/renders/c1d4f0…aa.pdf",
"url_expires_at": "2027-06-14T10:25:11.000Z",
"meta": { "pages": 3, "page_format": "A4", "bytes": 184220 },
"render_ms": 1203,
"credits_used": 2,
"cached": false,
"created_at": "2026-06-14T10:25:10.000Z",
"completed_at": "2026-06-14T10:25:11.203Z"
},
"message": "Success"
}Render from raw HTML
Skip the network entirely — send a fully-rendered HTML document (e.g. a server-rendered invoice) and get a PDF back.
POST /v1/pdf
curl https://api.renderkit.tech/v1/pdf \
-H "x-api-key: $RK_KEY" -H "Content-Type: application/json" \
-d '{ "html": "<h1>Invoice INV-2041</h1>…", "page_format": "A4", "footer_html": "<div style=\"font-size:9px\">Page</div>" }'