Skip to content

render.document

render.document(input: RenderInput) -> DocumentDescriptor

Render a PDF, store it server-side, return the descriptor (spec §5.2).

Name Type Required Description
input RenderInput required Render input. Same shape as `render.pdf`.

DocumentDescriptor — a DocumentDescriptor whose download_pdf() fetches the bytes on demand.

Code When
PROJECT_REQUIRED_FOR_DOCUMENT Input without a `project`. Rejected locally before the HTTP call.
VALIDATION_ERROR The request body failed validation.
INVALID_API_KEY The API key is malformed or revoked.
PROJECT_NOT_FOUND No project with this slug in the organization.
PROJECT_NOT_IN_ENVIRONMENT The project is not published in the key's environment.
TEMPLATE_NOT_FOUND The template is not in the project's copy published in the key's environment.
TEMPLATE_ERROR The engine rejected the template or its data.
TEMPLATE_UNSAFE The template, a partial or an SVG asset holds an injection attempt; `detail` names it.
EMPTY_DOCUMENT The render produced zero pages.
RENDER_BODY_TOO_LARGE The request body is over the API's size limit (413).
DOCUMENT_TOO_LARGE The document exceeds an engine cap (413).
QUOTA_EXCEEDED Monthly quota reached (429). Not retried: it lasts until the monthly reset.
OVERAGE_CAP_EXCEEDED Overage cap reached on a paid tier (429). Not retried: it lasts until the monthly reset.
RATE_LIMIT_EXCEEDED Per-key render rate limit reached. Retryable.
PUBLISH_IN_PROGRESS The project is being published into this environment (503 with `Retry-After`). Retryable.
RENDER_TIMEOUT The engine's time budget expired (504). Retryable.
timeout Request exceeded the configured `timeout`. Retryable.
network_error TCP/TLS-level failure reaching the API. Retryable.
STORAGE_ACCESS_DENIED The organization's own storage bucket refuses access (502). Not retried: restore the bucket role, then call again.
INTERNAL_ERROR The API returned 5xx. Retryable.
# Demonstrates: client.render.document(input) — render and store a PDF server-side.
from poli_page import PoliPage
client = PoliPage()
document = client.render.document({
"project": "billing",
"template": "invoice",
"data": {"invoiceNumber": "INV-001", "total": 1280},
"metadata": {"customerId": "cust_42"},
})
# `document.document_id` identifies the stored document — use it with
# client.documents.* to fetch, preview, thumbnail, or delete later.
print(
f"Stored as {document.document_id} "
f"({document.page_count} pages, {document.size_bytes} bytes)"
)
# Fetch the PDF bytes on demand:
pdf = document.download_pdf()
print(f"Downloaded {len(pdf)} bytes")