Rendering API

Render a page to PNG, SVG, or WebP via GET (by page ID) or POST (inline page data).

Rendering API

The Rendering API turns a Bannx page (from a template) into an image. You can either reference a published page by ID (GET or POST) or send full page data in the request body (POST).

Endpoints

GET /api/render/:pageId

Render a published page by ID. The page must exist and its template must be published so the page is available in the publish cache.

Authentication: Required (Authorization: Bearer <token>).

Query parameters:

ParameterTypeDescription
formatpng | svg | webpOutput format. Default: png.
tweaksstring (JSON)JSON object of variable overrides by name, e.g. {"title":"Hello","count":5}.
tweak:<name>string/number/booleanAlternative: per-variable overrides, e.g. tweak:title=Hello and tweak:count=5.

Response: Binary image (image/png, image/svg+xml, or image/webp).

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

POST /api/render

Render using either a page ID (published) or inline page data. Use inline data for one-off renders or when the page is not yet published.

Authentication: Required (Authorization: Bearer <token>).

Request body (JSON):

FieldTypeDescription
pageIdstringIf set: fetch this published page (and its template) from cache. Mutually exclusive with full inline page.
pageobjectInline page: width, height, layers, variables, bindings, etc. Use when not using pageId.
draftbooleanIf pageId is set and draft: true, load page (and template) from database instead of cache. Default: false.
formatpng | svg | webpOutput format. Default: png.
tweaksobjectVariable overrides by name (applied to page, template, and global variables).
globalVariablesarray or objectOptional; used with inline page.
templateVariablesarray or objectOptional; used with inline page.
emojiTypestringOptional; e.g. twemoji, openmoji. Default from template/space.

Response: Binary image (same as GET).

Example (by page ID):

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 out.webp

Example (inline page):

{
  "page": {
    "width": 1200,
    "height": 630,
    "backgroundColor": "#ffffff",
    "layers": [ ... ],
    "variables": [ ... ],
    "bindings": [ ... ]
  },
  "format": "png",
  "tweaks": { "title": "My Banner" }
}

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:

FieldTypeDescription
codestringRequired. Source code to render.
langstringLanguage for highlighting (e.g. js, ts). Default: js.
themestringShiki theme. Default: github-dark.
formatpng | webp | jpegDefault: webp.
width, height, quality, styleoptionalLayout and style options.

Response: Image (e.g. data URL or binary depending on implementation).

Errors

StatusMeaning
400 Bad RequestInvalid body or query (e.g. missing both pageId and page).
401 UnauthorizedMissing or invalid API token.
404 Not FoundPage or template not found (or not in cache when not using draft).
500 Internal Server ErrorRendering failed.

Webhooks

Render requests can trigger webhooks (e.g. upload result, update log). See Webhooks for configuration and behavior.

Copyright © 2026 bannx. All rights reserved.