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" } }
FieldTypeDescription
htmlstring, requiredThe HTML document to render. Maximum 2 MB. Inline CSS and <style> are supported; external resources are fetched relative to options.base_url.
optionsobject, optionalRendering options, all optional — see below.

Options

OptionTypeDescription
page_sizestringA4 (default), Letter, Legal, A3, A5 or WIDTHxHEIGHTmm
orientationstringportrait (default) or landscape
margins_mmnumber | objectUniform margin, or {top, right, bottom, left}; default 20
base_urlstringBase URL used to resolve relative images, stylesheets and fonts in the HTML
header_html / footer_htmlstringHTML rendered on every page; placeholders {page} and {pages}
wait_msintegerExtra delay after load before capture, 0–30000; for JavaScript-driven content
wait_for_selectorstringCapture once this CSS selector exists in the page
pdf_uabooleanProduce a tagged PDF/UA document from the HTML structure
pdf_astring2b, 2u, 3b — archival PDF/A conformance level
passwordobject{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.

ErrorHTTPMeaning
invalid_api_key401Header missing, key unknown, key revoked, or the account's email is not confirmed. The same code for every cause, deliberately.
account_suspended403The account is suspended. Portal login still works; contact support.
invalid_request400html missing, not a string, or larger than 2 MB; malformed JSON. detail says which.
quota_exceeded429No credits left. Buy a top-up or upgrade at app.rendarium.com/billing; the allowance also resets on your billing day. Not charged.
rate_limited429More than 10 requests per second on this key. Back off and retry; not charged.
conversion_failed500The 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