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_xxxxxxxxxxxxxxxx02. Base URL
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_urldirectly. - Timeout: 25 seconds.
Async Mode (wait=false)
Best for: Bulk jobs, background processes.
- Returns
job_idimmediately. - You poll the status endpoint.
- Default behavior.
04. HTML to PDF
Convert raw HTML string to PDF.
Try it out
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
}'// Click Send to see response...
Request Body
| Field | Type | Description |
|---|---|---|
| html | string | The full HTML content to render. |
| wait | boolean | If 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
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.
How it works
We support Handlebars and Jinja2 syntax. Define variables in your HTML using double curly braces.
<!-- HTML Template: 'invoice-v1' -->
<h1>Invoice #{{ invoice_number }}</h1>
<div className="items">
{{#each items}}
<p>{{ description }}: {{ price }}</p>
{{/each}}
</div>{
"data": {
"invoice_number": "IVO-001",
"items": [
{ "description": "API Plan", "price": "$29.00" }
]
},
"wait": true
}Ready to start? Sign up for an account to access the My Templates dashboard.
