Skip to content
API referencePDF

PDF

Stable

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

POSThttps://api.renderkit.tech/v1/pdf

url or html

Send exactly one of url or html. Requests with neither — or both — are rejected with 400 INVALID_PARAMS. Unknown fields are silently stripped before they reach the engine.

PDF parameters

ParameterDescription
page_formatstringStandard paper size. Options: A4, A3, A5, Letter, Legal, Tabloid. Defaults to A4.
landscapebooleanRotate the page to landscape orientation. Defaults to false.
print_backgroundbooleanRender background colors and images. Defaults to true.
scalenumberScale the rendered content (0.1–2). Defaults to 1.
marginstringUniform margin for all sides, e.g. "16mm" or "1in".
margin_topstringTop margin (overrides margin).
margin_rightstringRight margin (overrides margin).
margin_bottomstringBottom margin (overrides margin).
margin_leftstringLeft margin (overrides margin).
page_rangestringSubset of pages to emit, e.g. "1-3, 5".
page_widthstringCustom page width (overrides page_format), e.g. "210mm".
page_heightstringCustom page height (overrides page_format).
prefer_css_page_sizebooleanHonor the page's own @page size declaration. Defaults to false.
header_htmlstringHTML for a running page header (max 50 KB). Supports print tokens like page number.
footer_htmlstringHTML for a running page footer (max 50 KB).

Common parameters

ParameterDescription
urlstringFully-qualified URL to render. Max 4096 chars. Provide this or html, not both.
htmlstringRaw HTML to render instead of fetching a URL. Up to 2 MB. Provide this or url.
wait_untilstringNavigation lifecycle event to wait for before rendering. Options: load, domcontentloaded, networkidle. Defaults to networkidle.
delayintegerExtra wait after the page is ready, in milliseconds (0–10000). Defaults to 0.
timeoutintegerHard navigation timeout in milliseconds (5000–60000). Clamped to your plan's maximum. Defaults to 30000.
wait_for_selectorstringBlock until this CSS selector appears in the DOM.
user_agentstringOverride the browser User-Agent string.
countrygrowth+stringRender from a US or GB IP so geo-restricted and region-walled pages load correctly. Options: us, gb.
cookieshobby+arrayCookies to set before navigation. Up to 50 entries.
headershobby+objectExtra HTTP request headers, e.g. an Authorization header for gated pages.
inject_csshobby+stringCSS injected into the page before rendering (max 100 KB).
inject_jsgrowth+stringJavaScript executed in the page before rendering (max 100 KB).
cachebooleanServe an identical prior render from cache when available. Cache hits are free. Defaults to true.
cache_ttlintegerCache lifetime in seconds (0–2592000, i.e. up to 30 days). Defaults to 3600.
cache_keystringOverride the automatic cache key to force-share or force-separate renders.
asynchobby+booleanQueue the render and return a job immediately instead of blocking. See Webhooks & async. Defaults to false.
webhook_urlhobby+stringHTTPS URL that receives a signed render.done / render.failed callback when an async render finishes.
webhook_secrethobby+stringSecret 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>" }'