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[]Professional service agreement with scope, term, compensation, confidentiality, and signature blocks.
service_providerclient_namecontract_dateservices[]start_dateend_datepayment_amountgoverning_lawElegant certificate of achievement or completion with decorative border and authorized signature.
recipient_namecertificate_titlecertificate_typeorganizationdescriptionissue_dateauthorized_bycertificate_idFormal job offer letter with position details, compensation, benefits, and HR signature.
company_namecandidate_namepositionstart_datesalaryemployment_typebenefits[]offer_expiryhr_nameConverters
Use the same POST /v1/generate endpoint with different input fields to convert Markdown or images to PDF.
① Markdown → PDF
Pass any Markdown string — we render it into a beautifully styled PDF with proper headings, code blocks, and tables.
{
"markdown": "# Invoice Summary\n\nHere are the **Q1 results**:\n\n| Month | Revenue |\n|-------|---------|\n| Jan | $12,000 |\n| Feb | $15,400 |\n| Mar | $18,200 |"
}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({ markdown: "# Hello World\n\nThis is **bold** and this is _italic_." }),
});
const pdf = await res.arrayBuffer();② Image → PDF
Pass a public image URL (JPG, PNG, WebP, GIF, SVG) — we fetch it server-side and embed it in a clean PDF page.
{
"image_url": "https://example.com/photo.jpg",
"options": { "format": "A4" }
}Supported formats: JPEG, PNG, WebP, GIF, SVG · Max image size: 20MB · Private/internal URLs are blocked.
/v1/mergeMerge multiple PDFs into a single document. Pass an array of public PDF URLs — we fetch them in parallel and combine all pages in order.
{
"urls": [
"https://example.com/cover.pdf",
"https://example.com/report.pdf",
"https://example.com/appendix.pdf"
]
}const res = await fetch("https://api.renderpdfs.com/v1/merge", {
method: "POST",
headers: { "X-API-Key": "rpdf_your_key_here", "Content-Type": "application/json" },
body: JSON.stringify({
urls: [
"https://example.com/invoice.pdf",
"https://example.com/terms.pdf",
],
}),
});
const merged = await res.arrayBuffer();
fs.writeFileSync("merged.pdf", Buffer.from(merged));Parameters
| Field | Type | Required | Description |
|---|---|---|---|
urls | string[] | Yes | 2–20 public PDF URLs to merge in order |
store | boolean | No | If true, upload result to R2 and return a URL instead of binary |
Note: Each merge request counts as 1 usage regardless of how many PDFs are merged. Encrypted or password-protected PDFs will return an error.
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 |
Limits
Maximum payload sizes enforced per input type. Requests exceeding these limits return a 400 error with a descriptive message.
| Field | Max size | Notes |
|---|---|---|
html | 5 MB | Raw HTML string |
markdown | 1 MB | Markdown string |
image_url | 20 MB | Fetched server-side — URL itself is unlimited |
merge urls | 20 URLs | Each PDF fetched in parallel with a 15s timeout |
url (page capture) | — | No size limit — page load timeout is 30s |
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. Or use our official Node.js SDK:
Official Node.js SDK
npm install renderpdfsimport RenderPDFs from "renderpdfs";
const client = new RenderPDFs("rpdf_your_key");
// HTML → PDF
const pdf = await client.generate({ html: "<h1>Hello</h1>" });
// Invoice template
const invoice = await client.template("invoice", { company_name: "Acme", ... });
// Merge PDFs
const merged = await client.merge(["https://.../a.pdf", "https://.../b.pdf"]);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.pdfMCP ServerNEW
RenderPDFs exposes a Model Context Protocol (MCP) server — so AI assistants like Claude, Cursor, and Windsurf can generate PDFs directly from natural language, with no code required.
🤖 Example
“Generate an invoice PDF for ACME Corp, $1,200, due April 15th”
→ Claude calls generate_invoice_pdf and returns a download link automatically.
Setup
Add this to your AI client config. Replace your_api_key with your RenderPDFs key.
// Claude Desktop: ~/.claude/claude_desktop_config.json
// Cursor: ~/.cursor/mcp.json
{
"mcpServers": {
"renderpdfs": {
"url": "https://api.renderpdfs.com/mcp",
"headers": {
"X-API-Key": "your_api_key_here"
}
}
}
}Available Tools
| Tool | Description |
|---|---|
| generate_pdf_from_html | Convert HTML content to a PDF download URL |
| generate_pdf_from_url | Convert any webpage URL to a PDF download URL |
| generate_invoice_pdf | Generate a professional invoice from structured data |
| generate_receipt_pdf | Generate a receipt from transaction data |
| generate_contract_pdf | Generate a service agreement with parties, scope, and signature blocks |
| generate_certificate_pdf | Generate a certificate of achievement or completion |
| generate_offer_letter_pdf | Generate a job offer letter with compensation and benefits |
All tools return a download URL valid for 24 hours. Usage counts against your monthly plan quota.
Ready to start generating PDFs?
Get your free API key →