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[]
contract

Professional service agreement with scope, term, compensation, confidentiality, and signature blocks.

service_providerclient_namecontract_dateservices[]start_dateend_datepayment_amountgoverning_law
certificate

Elegant certificate of achievement or completion with decorative border and authorized signature.

recipient_namecertificate_titlecertificate_typeorganizationdescriptionissue_dateauthorized_bycertificate_id
offer-letter

Formal job offer letter with position details, compensation, benefits, and HR signature.

company_namecandidate_namepositionstart_datesalaryemployment_typebenefits[]offer_expiryhr_name

Converters

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.

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

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

POST/v1/merge

Merge multiple PDFs into a single document. Pass an array of public PDF URLs — we fetch them in parallel and combine all pages in order.

json
{
  "urls": [
    "https://example.com/cover.pdf",
    "https://example.com/report.pdf",
    "https://example.com/appendix.pdf"
  ]
}
javascript
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

FieldTypeRequiredDescription
urlsstring[]Yes2–20 public PDF URLs to merge in order
storebooleanNoIf 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.

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

Limits

Maximum payload sizes enforced per input type. Requests exceeding these limits return a 400 error with a descriptive message.

FieldMax sizeNotes
html5 MBRaw HTML string
markdown1 MBMarkdown string
image_url20 MBFetched server-side — URL itself is unlimited
merge urls20 URLsEach 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.

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. Or use our official Node.js SDK:

Official Node.js SDK

bash
npm install renderpdfs
typescript
import 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"]);
🟩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

MCP 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.

json
// 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

ToolDescription
generate_pdf_from_htmlConvert HTML content to a PDF download URL
generate_pdf_from_urlConvert any webpage URL to a PDF download URL
generate_invoice_pdfGenerate a professional invoice from structured data
generate_receipt_pdfGenerate a receipt from transaction data
generate_contract_pdfGenerate a service agreement with parties, scope, and signature blocks
generate_certificate_pdfGenerate a certificate of achievement or completion
generate_offer_letter_pdfGenerate 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 →