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

API Documentation

Simple, powerful PDF generation for developers.

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

04. 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=..."
}

05. 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
}

06. Hosted 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.