POST /convert/html
POSThttps://api.rendarium.com/convert/html
Converts an HTML string to PDF. Costs 1 credit per successful request on the hosted API; nothing in self-hosted mode. The example on the home page and the quick start call exactly this operation.
Request
POST /convert/html
Authorization: Bearer rnd_live_...
Content-Type: application/json
{ "html": "<h1>Hello</h1>", "options": { "page_size": "A4" } }
| Field | Type | Description |
|---|---|---|
html | string, required | The HTML document to render. Maximum 2 MB. Inline CSS and <style> are supported; external resources are fetched relative to options.base_url. |
options | object, optional | Rendering options, all optional — see below. |
Options
| Option | Type | Description |
|---|---|---|
page_size | string | A4 (default), Letter, Legal, A3, A5 or WIDTHxHEIGHTmm |
orientation | string | portrait (default) or landscape |
margins_mm | number | object | Uniform margin, or {top, right, bottom, left}; default 20 |
base_url | string | Base URL used to resolve relative images, stylesheets and fonts in the HTML |
header_html / footer_html | string | HTML rendered on every page; placeholders {page} and {pages} |
wait_ms | integer | Extra delay after load before capture, 0–30000; for JavaScript-driven content |
wait_for_selector | string | Capture once this CSS selector exists in the page |
pdf_ua | boolean | Produce a tagged PDF/UA document from the HTML structure |
pdf_a | string | 2b, 2u, 3b — archival PDF/A conformance level |
password | object | {user, owner, permissions} — encrypt the output |
Response
200 OK with Content-Type: application/pdf; the body is the PDF. Headers: Request-Id, Rendarium-Version, Content-Length.
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 18432
Request-Id: 7f1c9b2e-3a4d-4e5f-9a6b-1c2d3e4f5a6b
Errors
Every error is JSON {"error": "<code>", "detail": "..."}. Codes are stable identifiers to branch on; detail is for humans and may change.
| Error | HTTP | Meaning |
|---|---|---|
invalid_api_key | 401 | Header missing, key unknown, key revoked, or the account's email is not confirmed. The same code for every cause, deliberately. |
account_suspended | 403 | The account is suspended. Portal login still works; contact support. |
invalid_request | 400 | html missing, not a string, or larger than 2 MB; malformed JSON. detail says which. |
quota_exceeded | 429 | No credits left. Buy a top-up or upgrade at app.rendarium.com/billing; the allowance also resets on your billing day. Not charged. |
rate_limited | 429 | More than 10 requests per second on this key. Back off and retry; not charged. |
conversion_failed | 500 | The engine could not render the document. The reserved credit is refunded and the request appears as failed in your dashboard. Retry, or contact support with the request id. |
All operations and credit costs: see the API index page (every operation listed, 1 credit each; measure, health and version are free).
Example: invoice with header and footer
curl -X POST https://api.rendarium.com/convert/html \
-H "Authorization: Bearer rnd_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Invoice #1024</h1><table>...</table>",
"options": {
"page_size": "A4",
"margins_mm": { "top": 25, "right": 15, "bottom": 20, "left": 15 },
"header_html": "<div style=\"font-size:10px\">Acme Ltd</div>",
"footer_html": "<div style=\"font-size:10px;text-align:right\">Page {page} of {pages}</div>"
}
}' --output invoice.pdf