Building a PDF feature?
Save this to your Work Desktop.

API Documentation

Generate invoices, quotes & receipts from JSON — or convert any HTML/URL to PDF.

01. Authentication

Authenticate your requests using the X-API-Key header. You can generate a key in your dashboard.

Header Example

X-API-Key: pmh_live_xxxxxxxxxxxxxxxx

02. Base URL

https://api.pdfmyhtml.com

03. Document Generation

Don't build invoice HTML by hand. Send structured JSON (parties, line items, tax) to a ready-made template and get a polished PDF back. Three document types, each with multiple styles. The server computes all totals — you never send a precomputed total.

POST/v1/invoices
Request
{
  "style": "modern",
  "number": "INV-2026-001",
  "currencySymbol": "$",
  "taxRate": 10,
  "from": { "name": "Acme Corp", "address": "1 Market St\nSF, CA" },
  "to":   { "name": "Client Inc", "address": "9 Commerce Ave\nNY, NY" },
  "items": [
    { "description": "Design work", "quantity": 10, "rate": 150 },
    { "description": "Hosting",     "quantity": 12, "rate": 45  }
  ],
  "wait": true
}
cURL
curl -X POST https://api.pdfmyhtml.com/v1/invoices \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{ "style": "modern", "taxRate": 10,
        "from": {"name":"Acme"}, "to": {"name":"Client"},
        "items": [{"description":"Work","quantity":10,"rate":150}],
        "wait": true }'

Document types & styles

EndpointTypeStyles
/v1/invoicesInvoicemodern · classic · minimal · brutalist · startup
/v1/quotesQuote / Estimatemodern · classic (+ validUntil, terms)
/v1/receiptsReceiptthermal · modern (business, cashier)

Each generated document costs 1 credit — the same pool as HTML/URL conversions. Prefer to design your own layout? See Custom Templates.

04. Live Preview

POST/v1/preview· no API key · returns HTML

Render any document type to HTML (not PDF) for an instant on-screen preview. No API key, no credit consumed — rate-limited per IP. This is the exact engine that powers our free invoice generator, so what you preview is what you download.

{
  "docType": "invoice",
  "style": "modern",
  "data": { "from": {"name":"Acme"}, "to": {"name":"Client"},
            "items": [{"description":"Work","quantity":1,"rate":100}] }
}

05. Sync vs Async

Our API works in two modes via the wait parameter:

Sync Mode (wait=true)

Best for: User-facing apps requiring instant downloads.

  • Request stays open until PDF is ready.
  • Returns download_url directly.
  • Timeout: 25 seconds.

Async Mode (wait=false)

Best for: Bulk jobs, background processes.

  • Returns job_id immediately.
  • You poll the status endpoint.
  • Default behavior.

06. HTML to PDF

POST/v1/html-to-pdf

Convert raw HTML string to PDF.

Try it out

POST
https://api.pdfmyhtml.com/v1/html-to-pdf
Body
curl -X POST "https://api.pdfmyhtml.com/v1/html-to-pdf" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
  "html": "<h1>Hello World!</h1>",
  "wait": true
}'
RESPONSE
// Click Send to see response...

Request Body

FieldTypeDescription
htmlstringThe full HTML content to render.
waitbooleanIf true, waits for completion. Default: false.

Successful Response

{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "COMPLETED",
  "download_url": "https://s3.amazonaws.com/bucket/file.pdf?signature=..."
}

07. URL to PDF

POST/v1/url-to-pdf

Similar to HTML endpoint, but accepts a public URL.

Request Body

{
  "url": "https://example.com/invoice",
  "wait": true
}

08. Custom Templates

Stop hardcoding HTML strings in your backend.

With Hosted Templates, you can store your HTML layouts in our dashboard and simply send the JSON data when generating a PDF. This keeps your codebase clean and allows non-developers to update invoice designs without deploying code.

1. Storage

Save standard, reusable templates (Invoices, Reports, Certificates) in your dashboard.

2. Live Preview

Edit HTML/CSS with a realtime visual preview. Test with sample JSON data instantly.

3. Integration

Get copy-paste ready API snippets for each template directly from the editor.

POST/v1/templates/:id/render

How it works

We support Handlebars and Jinja2 syntax. Define variables in your HTML using double curly braces.

Your Template (Saved in Dashboard)
<!-- HTML Template: 'invoice-v1' -->
<h1>Invoice #{{ invoice_number }}</h1>
<div className="items">
  {{#each items}}
    <p>{{ description }}: {{ price }}</p>
  {{/each}}
</div>
Your API Call
{
  "data": {
    "invoice_number": "IVO-001",
    "items": [
      { "description": "API Plan", "price": "$29.00" }
    ]
  },
  "wait": true
}

Live Editor Demo

Live Template Editor Demo

Stop coding blindly.

Ready to start? Sign up for an account to access the My Templates dashboard.