Render input
Every render method (render.pdf, render.pdf_stream, render.document, and the render_to_file helper) takes the same input, the RenderInput TypedDict in the types reference: a project slug, a template slug inside it, and a data mapping that fills the template’s placeholders.
Required fields
Section titled “Required fields”pdf = client.render.pdf({ "project": "billing", "template": "invoice", "data": {"invoiceNumber": "INV-001", "total": 1280},})There is no version to pick: the API renders the project’s copy published in the API key’s environment (see Authentication). To render your own templates, publish the project to that environment first. Input without a project raises PoliPageError(code="PROJECT_REQUIRED_FOR_DOCUMENT") locally — no HTTP round-trip is wasted.
Optional fields
Section titled “Optional fields”format— a page format such as"A4"or"Letter".orientation—"portrait"or"landscape".locale— a BCP 47 tag (e.g."en-US").metadata— your own primitive-valued audit data, echoed on theDocumentDescriptor.idempotency_key— overrides the auto-generatedIdempotency-Keyheader.timeout— a per-call deadline in seconds, overriding the client’stimeout.
The request body carries only project, template, data, metadata, format, orientation and locale. An unset or None field is left out, so the API’s defaults apply, and any other key in the dict is not sent.
Previews and inline HTML
Section titled “Previews and inline HTML”The API renders published templates only. To preview a template or render inline HTML while you design it, use the playground at play.poli.page. client.documents.preview(id) returns the stored HTML of a document you already rendered.
Example
Section titled “Example”from poli_page import PoliPage
client = PoliPage()
invoice_pdf = client.render.pdf({ "project": "billing", "template": "invoice", "data": {"invoiceNumber": "INV-001", "total": 1280}, "format": "A4", "orientation": "portrait", "metadata": {"customer_id": "cust_123"},})