Quick start
This page walks through your first render — from key to PDF — without touching the dashboard. It uses the getting-started project that every organization gets in its sandbox environment.
Set your API key
Section titled “Set your API key”Create a key in your organization’s sandbox environment (it starts with pp_sandbox_) and export it into the environment your script runs in:
export POLI_PAGE_API_KEY=pp_sandbox_x # replace with your full keySee Authentication for the key format and what each environment does.
Render a PDF
Section titled “Render a PDF”from poli_page import PoliPage
client = PoliPage() # picks up POLI_PAGE_API_KEY from the environment
pdf = client.render.pdf({ "project": "getting-started", "template": "welcome", "data": {"name": "SDK Demo"},})pdf is bytes. Write it to disk, upload it to S3, or return it directly from a web handler.
Every organization gets a getting-started project, published into its sandbox environment when the organization is created, with a welcome template, so this runs as-is on a fresh organization. It is a normal, editable project: in an organization that renamed it, deleted it or removed it from sandbox, the API answers 404 PROJECT_NOT_FOUND or 404 PROJECT_NOT_IN_ENVIRONMENT, so use a fresh organization to follow along.
Your own templates
Section titled “Your own templates”There is no version to pick: a render uses the project’s copy published in the API key’s environment. Publish your project to the environment of the key you render with, then swap the slugs. To preview a template or render inline HTML while you design it, use the playground at play.poli.page.
Example
Section titled “Example”from pathlib import Pathfrom poli_page import PoliPage
client = PoliPage() # picks up POLI_PAGE_API_KEY from the environment
pdf = client.render.pdf({ "project": "getting-started", "template": "welcome", "data": {"name": "SDK Demo"},})
Path("./welcome.pdf").write_bytes(pdf)