Documentation
AIVEXA PDF API converts HTML and URLs to PDF using headless Chromium. Full JavaScript support, custom fonts, CSS print styles, and all standard PDF options.
Overview
The AIVEXA PDF API is a REST API that accepts HTML markup or a publicly accessible URL and returns a professionally rendered PDF file. The rendering engine is based on Chromium, which means the output is identical to what you would see in a Chrome browser with Print to PDF.
Base URL: https://aivexa.com/api/v1
Quick Start
1. Sign up and create an API key in your dashboard.
2. Make a POST request:
curl -X POST https://aivexa.com/api/v1/pdf \
-H "Authorization: Bearer avx_pdf_live_xxx" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello World</h1>", "format": "A4"}' \
--output document.pdf3. The response is a binary PDF. Save it directly to a file with --output.
Authentication
All API requests require an API key sent in the Authorization header:
Authorization: Bearer avx_pdf_live_YOUR_KEY
| Key Type | Prefix | Behaviour |
|---|---|---|
| Live | avx_pdf_live_ | Consumes credits, production use |
| Test | avx_pdf_test_ | Free, no credits consumed, for development |
⚠️ Never expose API keys in browser JavaScript, public repositories, or client-side code.
HTML to PDF
POST /api/v1/pdf
| Parameter | Type | Required | Description |
|---|---|---|---|
html | string | Yes | Full HTML markup to convert |
format | string | No | A3, A4, A5, A6, Letter, Legal, Tabloid. Default: A4 |
orientation | string | No | portrait or landscape. Default: portrait |
margin | object | No | {top, right, bottom, left} in mm. e.g. "10mm" |
printBackground | boolean | No | Print background colors and images. Default: true |
scale | number | No | Content scale 0.1–2.0. Default: 1 |
mediaType | string | No | print or screen. Default: screen |
displayHeaderFooter | boolean | No | Enable header and footer |
headerTemplate | string | No | HTML for page header |
footerTemplate | string | No | HTML for page footer |
waitForSelector | string | No | CSS selector to wait for before rendering |
waitUntil | string | No | load | domcontentloaded | networkidle0 | networkidle2 |
delay | number | No | Delay in ms before rendering (max 10000) |
filename | string | No | PDF filename in Content-Disposition header |
URL to PDF
POST /api/v1/url-to-pdf
Same options as HTML to PDF, but accepts a url parameter instead of html. The URL must be publicly accessible. Private IPs, localhost, and metadata endpoints are blocked.
{
"url": "https://example.com/invoice/123",
"format": "A4",
"waitForSelector": "#invoice-loaded",
"waitUntil": "networkidle0"
}Screenshot
POST /api/v1/screenshot
| Parameter | Type | Description |
|---|---|---|
html / url | string | HTML markup or public URL (one required) |
format | string | png or jpeg. Default: png |
fullPage | boolean | Capture full scrollable page. Default: false |
viewportWidth | number | Viewport width in px. Default: 1280 |
viewportHeight | number | Viewport height in px. Default: 800 |
quality | number | JPEG quality 1–100. Default: 90 |
Errors
All errors return a JSON body with consistent structure:
{
"error": {
"code": "QUOTA_EXCEEDED",
"message": "Monthly PDF quota exceeded. Upgrade your plan to continue.",
"request_id": "req_01KXX..."
}
}| Code | HTTP | Meaning |
|---|---|---|
MISSING_API_KEY | 401 | No Authorization header provided |
INVALID_API_KEY | 401 | Key does not exist |
API_KEY_REVOKED | 401 | Key was revoked |
QUOTA_EXCEEDED | 429 | Monthly credit limit reached |
RATE_LIMIT_EXCEEDED | 429 | Too many requests per minute |
INVALID_HTML | 400 | HTML could not be rendered |
INVALID_URL | 400 | URL is not valid HTTP/HTTPS |
BLOCKED_URL | 400 | URL points to private address |
HTML_TOO_LARGE | 400 | HTML exceeds 10 MB limit |
RENDERING_TIMEOUT | 500 | Rendering exceeded time limit |
BROWSER_ERROR | 500 | Unexpected browser error |
INTERNAL_ERROR | 500 | Server-side error |
Rate Limits
Rate limits are per API key, per minute:
| Plan | Requests/min |
|---|---|
| Free | 5 |
| Starter | 20 |
| Growth | 50 |
| Pro | 150 |
Rate limit headers are included in every response:
X-RateLimit-Limit: 20 X-RateLimit-Remaining: 18 X-Request-ID: req_01KXX...