API Reference
Everything you need to generate PDFs programmatically.
Authentication
All requests require an API key passed in the X-API-Key header. Get your key by creating a free account.
POST /v1/generate HTTP/1.1
Host: api.renderpdfs.com
X-API-Key: rpdf_your_key_here
Content-Type: application/jsonKeep your key secret. Never expose it in client-side code or public repositories.
/v1/generateGenerate a PDF from raw HTML or a built-in template. Returns a PDF binary.
① Raw HTML
Send any HTML string — full CSS support included.
{
"html": "<h1 style='font-family:sans-serif'>Hello World</h1>",
"options": {
"format": "A4",
"margin": "20mm",
"landscape": false
}
}② Built-in Template
Pass a template name and JSON data — we render it for you.
{
"template": "invoice",
"data": {
"company_name": "Acme Corp",
"client_name": "John Doe",
"invoice_number": "INV-001",
"issue_date": "2026-03-12",
"due_date": "2026-04-12",
"status": "due",
"items": [{ "description": "Web Dev", "quantity": 1, "unit_price": "$1,500", "amount": "$1,500" }],
"total": "$1,500.00"
}
}③ URL to PDF
Pass any public URL — we load the full page and capture it as a PDF.
{
"url": "https://example.com",
"options": {
"format": "A4",
"margin": "10mm"
}
}curl -X POST https://api.renderpdfs.com/v1/generate \
-H "X-API-Key: rpdf_your_key_here" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com"}' \
--output page.pdfNote: The URL must be publicly accessible. JavaScript-heavy pages are fully rendered before capture.
Response
Returns a PDF binary with Content-Type: application/pdf
curl -X POST https://api.renderpdfs.com/v1/generate \
-H "X-API-Key: rpdf_your_key_here" \
-H "Content-Type: application/json" \
-d '{"template":"invoice","data":{...}}' \
--output invoice.pdfFull example (JavaScript)
const res = await fetch("https://api.renderpdfs.com/v1/generate", {
method: "POST",
headers: {
"X-API-Key": "rpdf_your_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
template: "invoice",
data: { company_name: "My Co", client_name: "Jane Doe", invoice_number: "INV-042", total: "$2,400.00" },
}),
});
const pdf = await res.arrayBuffer();
fs.writeFileSync("invoice.pdf", Buffer.from(pdf));Templates
Built-in templates powered by Handlebars. Pass your data and get a styled PDF instantly.
Professional invoice with line items, subtotal, tax, total, and a paid/due status badge.
company_nameclient_nameinvoice_numberissue_datedue_dateitems[]totalstatusCompact monospace-style receipt. Great for POS systems and e-commerce order confirmations.
company_namereceipt_numberdateitems[]totalpayment_methodMulti-section document with title, author, paragraphs, and optional data tables per section.
titleauthordateorganizationsections[]Options
Control the PDF output format via the optional options object.
| Field | Type | Default | Description |
|---|---|---|---|
format | string | A4 | Page size: "A4", "A3", or "Letter" |
margin | string | 20mm | Margin on all sides. Any CSS unit (mm, px, cm) |
landscape | boolean | false | Rotate page to landscape orientation |
Rate Limits
Requests are limited per API key per minute, in addition to the monthly quota.
| Plan | Requests / minute | Requests / month |
|---|---|---|
| Free | 10 | 100 |
| Starter | 30 | 500 |
| Pro | 100 | 5,000 |
When a rate limit is hit, the API returns 429 with a retryAfter field (in seconds).
File Storage
Add "store": true to get back a download URL instead of raw bytes. The URL is valid for 24 hours.
{
"html": "<h1>Invoice</h1>",
"store": true
}Response:
{
"url": "https://files.renderpdfs.com/pdfs/abc123.pdf",
"expires_in": 86400
}Tip: Use store: true for async workflows, email attachments, or anywhere you need a shareable link.
Error Codes
All errors return JSON with an error field.
{ "error": "Monthly quota exceeded", "used": 50, "limit": 50, "plan": "free" }| Status | Meaning |
|---|---|
| 200 | PDF generated successfully |
| 400 | Bad request — provide "html", "url", or "template" |
| 401 | Missing or invalid X-API-Key |
| 429 | Monthly quota exceeded — upgrade your plan |
| 500 | PDF generation failed (check your HTML for errors) |
SDKs & Examples
The API is plain HTTP — use it from any language.
const res = await fetch(URL, {
method: "POST",
headers: { "X-API-Key": KEY },
body: JSON.stringify({ html }),
});
const pdf = await res.arrayBuffer();import requests
r = requests.post(URL,
headers={"X-API-Key": KEY},
json={"html": html})
with open("out.pdf","wb") as f:
f.write(r.content)$ch = curl_init(URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,
["X-API-Key: $key"]);
$pdf = curl_exec($ch);curl -X POST $URL \
-H "X-API-Key: $KEY" \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Hi</h1>"}' \
-o output.pdfReady to start generating PDFs?
Get your free API key →