Skip to content

HTTP API

The service exposes a small HTTP API. All print requests must use Content-Type: application/json and bearer authentication with API_TOKEN.

Routes

MethodPathDescription
POST/printValidates, renders, and submits a print job.
GET/healthzReturns the service's liveness status.
GET/openapi.jsonReturns the generated OpenAPI document.
GET/docsShows the Scalar API reference when EXPOSE_DOCS=true.
GET/llms.txtReturns generated Markdown API documentation when EXPOSE_LLMS_TXT=true.
sh
curl -X POST "http://localhost:3000/print" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN" \
  --data '{
    "blocks": [
      {
        "type": "text",
        "content": "Hello from print-blocks",
        "align": "center",
        "bold": true
      },
      {
        "type": "qrcode",
        "content": "https://example.com",
        "align": "center"
      }
    ]
  }'

Success returns:

json
{
  "ok": true
}

This means the job was rendered and accepted by CUPS, not that physical printing has completed.

Errors

Errors use a stable JSON envelope:

json
{
  "ok": false,
  "error": {
    "message": "Request body did not match the print request schema.",
    "issues": {}
  }
}

Validation failures include an issues tree identifying invalid fields. The generated /openapi.json and optional /docs page contain the complete request contract for the running server.

Last updated: