API Reference

Everything you need to generate PDFs programmatically.

v1https://api.renderpdfs.com

Authentication

All requests require an API key passed in the X-API-Key header. Get your key by creating a free account.

http
POST /v1/generate HTTP/1.1
Host: api.renderpdfs.com
X-API-Key: rpdf_your_key_here
Content-Type: application/json

Keep your key secret. Never expose it in client-side code or public repositories.

POST/v1/generate

Generate a PDF from raw HTML or a built-in template. Returns a PDF binary.

Raw HTML

Send any HTML string — full CSS support included.

json
{
  "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.

json
{
  "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.

json
{
  "url": "https://example.com",
  "options": {
    "format": "A4",
    "margin": "10mm"
  }
}
bash
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.pdf

Note: The URL must be publicly accessible. JavaScript-heavy pages are fully rendered before capture.

Response

Returns a PDF binary with Content-Type: application/pdf

bash
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.pdf

Full example (JavaScript)

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.

invoice

Professional invoice with line items, subtotal, tax, total, and a paid/due status badge.

company_nameclient_nameinvoice_numberissue_datedue_dateitems[]totalstatus
receipt

Compact monospace-style receipt. Great for POS systems and e-commerce order confirmations.

company_namereceipt_numberdateitems[]totalpayment_method
report

Multi-section document with title, author, paragraphs, and optional data tables per section.

titleauthordateorganizationsections[]

Options

Control the PDF output format via the optional options object.

FieldTypeDefaultDescription
formatstringA4Page size: "A4", "A3", or "Letter"
marginstring20mmMargin on all sides. Any CSS unit (mm, px, cm)
landscapebooleanfalseRotate page to landscape orientation

Rate Limits

Requests are limited per API key per minute, in addition to the monthly quota.

PlanRequests / minuteRequests / month
Free10100
Starter30500
Pro1005,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.

json
{
  "html": "<h1>Invoice</h1>",
  "store": true
}

Response:

json
{
  "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.

json
{ "error": "Monthly quota exceeded", "used": 50, "limit": 50, "plan": "free" }
StatusMeaning
200PDF generated successfully
400Bad request — provide "html", "url", or "template"
401Missing or invalid X-API-Key
429Monthly quota exceeded — upgrade your plan
500PDF generation failed (check your HTML for errors)

SDKs & Examples

The API is plain HTTP — use it from any language.

🟩Node.js
const res = await fetch(URL, {
  method: "POST",
  headers: { "X-API-Key": KEY },
  body: JSON.stringify({ html }),
});
const pdf = await res.arrayBuffer();
🐍Python
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)
🐘PHP
$ch = curl_init(URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,
  ["X-API-Key: $key"]);
$pdf = curl_exec($ch);
cURL
curl -X POST $URL \
  -H "X-API-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Hi</h1>"}' \
  -o output.pdf

Ready to start generating PDFs?

Get your free API key →