Rendering API
The Rendering API turns a Bannx page (from a template) into an image. Use a page ID with GET or POST: by default the page is loaded from the publish cache; set draft: true on POST to load from the database (unpublished).
Endpoints
GET /api/render/:pageId
Render a page by ID using query parameters. By default loads from the publish cache; set draft=true to load from the database (same as POST).
Authentication depends on the template setting Require token for GET render (editor → Settings → Template):
- On (default): Send
Authorization: Bearer <API key>or add the space GET render URL secret as query paramgt(create it under Settings → Space → Developers). The API key must belong to the same space as the template. Useful for<img src="...">without request headers. - Off: No auth; anyone with the page ID can call GET for that template’s pages.
Query parameters:
| Parameter | Type | Description |
|---|---|---|
format | png | svg | webp | pdf | Output format. Default: png. |
draft | boolean | If true, load from database instead of publish cache. Default: false. |
output | json | binary | Response shape: omit or json for metadata + file URL; binary for raw bytes. |
templateId | string | Optional; validated against the page’s template. |
renderType | satori | takumi | html | Override renderer (ignored when format=pdf). |
emojiType | string | Override emoji set (e.g. twemoji, openmoji). |
pageIds | string | Comma-separated page IDs for merged PDF (format=pdf). |
tweaksPerPage | string (JSON) | Per-page tweaks aligned with pageIds for PDF. |
tweaks | string (JSON) | JSON object of variable overrides by name, e.g. {"title":"Hello","count":5}. |
brandTweaks | string (JSON) | Brand token overrides by dot path. |
tweak:<name> | string/number/boolean | Alternative: per-variable overrides, e.g. tweak:title=Hello. |
gt | string | When auth is required: GET render secret (space-level), alternative to Authorization. |
Response: Binary image/PDF, or application/json with file metadata when output is not binary.
Example:
# PNG (default)
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://your-app.bannx.app/api/render/PAGE_ID" -o out.png
# WebP with variable overrides (JSON)
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://your-app.bannx.app/api/render/PAGE_ID?format=webp&tweaks=%7B%22title%22%3A%22Hello%22%7D" -o out.webp
# SVG with query tweaks
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://your-app.bannx.app/api/render/PAGE_ID?format=svg&tweak:title=Hello" -o out.svg
# Same request using GET URL secret (no Bearer)
curl "https://your-app.bannx.app/api/render/PAGE_ID?format=png>=YOUR_GET_SECRET" -o out.png
POST /api/render
Render using a page ID. Loads the page and template from the publish cache by default, or from the database when draft: true (e.g. before publish).
Authentication: Required (Authorization: Bearer <token>).
Request body (JSON):
| Field | Type | Description |
|---|---|---|
pageId | string | Required for png, svg, webp. For pdf, use pageId (single page) or pageIds (merged PDF). |
pageIds | string | Optional. Multiple pages for a merged PDF when format is pdf. |
tweaksPerPage | object | Optional. Per-page tweaks; length must match pageIds when provided. |
templateId | string | Optional; when set, validated against the page’s template (can speed up parallel fetch). |
draft | boolean | If true, load page and template from the database instead of cache. Default: false. |
format | png | svg | webp | pdf | Output format. Default: png. pdf uses the HTML + Chrome pipeline (one credit per page). |
tweaks | object | Variable overrides by name (applied to page, template, and global variables). |
emojiType | string | Optional; e.g. twemoji, openmoji. Default from template/space. |
output | string | Optional. json (default when omitted) returns metadata JSON; binary, image, or raw returns the raw image body. |
binary | boolean | Optional. If true, same as output: "binary". |
Response (default): application/json with pageId, templateId, draft, format, mimeType, width, height, emojiType, renderMs, uploadMs, and file (id, url, sizeBytes). The render is uploaded to temporary storage for your space; use file.url to display or download the image.
Response (with "output": "binary" or "binary": true in the body): Raw body — image types as GET, or application/pdf when format is pdf.
Example (JSON default — save response and inspect file.url):
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"pageId":"PAGE_ID","format":"webp","tweaks":{"title":"Hello"}}' \
"https://your-app.bannx.app/api/render" -o response.json
Example (raw image body):
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"pageId":"PAGE_ID","format":"webp","output":"binary","tweaks":{"title":"Hello"}}' \
"https://your-app.bannx.app/api/render" -o out.webp
Example (draft / unpublished page):
{
"pageId": "PAGE_ID",
"draft": true,
"format": "png",
"tweaks": { "title": "My Banner" }
}
Example (single-page PDF):
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"pageId":"PAGE_ID","format":"pdf","output":"binary"}' \
"https://your-app.bannx.app/api/render" -o out.pdf
Example (merged multi-page PDF):
{
"pageIds": ["PAGE_A", "PAGE_B"],
"format": "pdf",
"output": "binary",
"tweaksPerPage": [{ "title": "Page A" }, { "title": "Page B" }]
}
Code-to-image (POST /api/code-to-image)
Separate endpoint to render code snippets as images (syntax highlighting). No API token required for this endpoint.
Request body:
| Field | Type | Description |
|---|---|---|
code | string | Required. Source code to render. |
lang | string | Language for highlighting (e.g. js, ts). Default: js. |
theme | string | Shiki theme. Default: github-dark. |
format | png | webp | jpeg | Default: webp. |
width, height, quality, style | optional | Layout and style options. |
Response: Image (e.g. data URL or binary depending on implementation).
Errors
| Status | Meaning |
|---|---|
400 Bad Request | Invalid body or query (e.g. missing pageId, or token=… in query — use gt or Authorization). |
401 Unauthorized | Missing or invalid auth when the template requires GET token. |
404 Not Found | Page or template not found (or not in cache when not using draft). |
500 Internal Server Error | Rendering failed. |
Webhooks
Render requests can trigger webhooks (e.g. upload result, update log). See Webhooks for configuration and behavior.