Render a label preview as PNG
const url = 'https://example.com/api/v1/render/preview';const options = { method: 'POST', headers: {'X-Label-Hub-Key': '<X-Label-Hub-Key>', 'Content-Type': 'application/json'}, body: '{"content_type":"qr_only","data":{"items":[],"primary_id":"example","qr_payload":"example","secondary":[],"title":"example"},"layout_preset":"compact","orientation":"across","tape_mm":12}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/render/preview \ --header 'Content-Type: application/json' \ --header 'X-Label-Hub-Key: <X-Label-Hub-Key>' \ --data '{ "content_type": "qr_only", "data": { "items": [], "primary_id": "example", "qr_payload": "example", "secondary": [], "title": "example" }, "layout_preset": "compact", "orientation": "across", "tape_mm": 12 }'Render a label using the LayoutEngine and return the result as a PNG image (no printer interaction, no job created). Useful for UI preview and debugging. Renders through the same engine call as a print job, so orientation and layout_preset give the exact image the job would print (an along image is the landscape band before the printer backend rotates it). Returns 422 when data is missing fields required by content_type or the QR payload does not fit the fixed QR code (qr_payload_too_long). Returns 409 when tape_mm is not a supported tape width or the orientation is not available for it.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Request body for POST /render/preview.
Phase 1k.1a (Task 25): render-only endpoint — no printer, no queue, no DB.
object
Tape-independent semantic content types for label rendering.
Raw label payload accepted when the client supplies data directly.
Mirrors LabelData minus source_app (set server-side to ‘manual’).
All content fields are optional — ContentType-specific validation
happens in LayoutEngine._validate_data.
Every free text is bounded at the request (the same caps as sheet items): 512 characters
per text and QR payload, at most 10 secondary lines and 100 items. A label shows
far less; the renderer shortens what does not fit (#258 security review).
object
The built-in QL 62 mm across-width layouts (docs/design/ql-layout-presets).
How the label content runs on endless tape.
Responses
Section titled “Responses”PNG label bitmap
Unsupported tape width or orientation
Data missing required fields, or QR payload too long