Docs / PDF
HTML to PDF API
GET /v1/pdf converts a URL; POST /v1/pdf converts inline HTML. Both return a print-ready PDF. Authenticated and metered.
01
From a URL
curl -H "Authorization: Bearer $SHOTPDF_KEY" \ "https://shotpdf.astraeatech.dev/v1/pdf?url=https://example.com&format=A4" \ -o page.pdf
02
From inline HTML
curl -H "Authorization: Bearer $SHOTPDF_KEY" -H "Content-Type: application/json" \
-d '{"html":"<h1>Invoice #42</h1><p>Thanks for your business.</p>","format":"Letter"}' \
https://shotpdf.astraeatech.dev/v1/pdf -o invoice.pdf
POST bodies are capped at 256 KB (larger requests get HTTP 413) and must use Content-Type: application/json (else HTTP 415).
03
Options
url(GET) /html(POST)required — Absolute http(s) URL, or a non-empty inline HTML string.formatA4 —A4orLetter(case-insensitive).margin10 — Uniform page margin in millimetres, 0–100.print_bgtrue —false/0drops CSS backgrounds for ink-friendly output.ttl86400 — Cache freshness in seconds, 0–604800.0bypasses the cache.
GET reads options from the query string; POST reads the same names from the JSON body.
04
Caching and errors
Rendered PDFs are byte-cached like screenshots (X-Cache: HIT/MISS), and cached responses still count as one metered request each. Invalid options return 400, a missing key 401 invalid_api_key, quota exhaustion HTTP 429 — all in the shared JSON envelope. Back to the docs index.