Skip to content

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.

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.

  • 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 the DocumentDescriptor.
  • idempotency_key — overrides the auto-generated Idempotency-Key header.
  • timeout — a per-call deadline in seconds, overriding the client’s timeout.

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.

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.

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"},
})