Files
uberbringer/docs/api.md
T
57_WolveandClaude Opus 5.5 9e829bfce7 Take a module route's copies and printer in its JSON body
API inputs go in the JSON body, never in query parameters (owner,
2026-12-01; design.md, "Inputs go in the JSON body"). The module routes
took copies and printer in the query, beside a body that was the
module's payload alone.

The body of POST /api/v1/print/{module} and /api/v1/preview/{module}
now holds the payload under payload, with copies and printer beside it:
{"payload": {...}, "copies": 2, "printer": "default"}. A module may name
its payload's fields as it likes, since none can collide with copies or
printer; that matters for ntfy's messages and for any module that takes
another system's JSON. The body is decoded strictly, and its problems
are answered at once as invalid_payload, each named by its path in the
body: copies, or, once the body is right, payload.done[0] for one the
module finds. A field named body is quoted, "body", so it is never
taken for a problem with the whole body. copies takes 0-5, as a job's
does, 0 meaning one. A query string on these routes gets 400
invalid_query, now worded "query parameters are not accepted".

The ntfy client recipes in docs/api.md wrap $NTFY_RAW in the body. The
Windows command was run here through cmd.exe and PowerShell, and the
printf of the Linux one in sh, each with a message holding quotes, & and
%; neither ran under an ntfy client. No tag carries the module query, so
the 0.2.0 entries in the CHANGELOG change in place (owner, 2026-12-01).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 22:29:02 -06:00

1033 lines
51 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Überbringer API
The HTTP API, the print elements and blocks, the modules, and the error
codes. [README.md](../README.md) links to the docs on installing,
configuring and running the daemon.
## Contents
- [API](#api)
- [Print a receipt](#print-a-receipt)
- [Job status](#job-status)
- [Preview a receipt](#preview-a-receipt)
- [Health](#health)
- [Errors](#errors)
- [Elements](#elements)
- [Blocks](#blocks)
- [Glyphs and code pages](#glyphs-and-code-pages)
- [Modules](#modules)
- [`note`](#note)
- [`notify`](#notify)
- [`ntfy`](#ntfy)
- [Notification cards](#notification-cards)
- [Digests](#digests)
## API
All `/api/v1` routes need an `Authorization: Bearer <token>` header. Issue
tokens with `uberbringer token`. Tokens created by the old install script keep
working as long as the secret is unchanged. Tokens in query strings are not
accepted, because they leak into proxy logs.
Keep a token off command lines too, where other users of the machine can
read it. The examples here send the header from a file only you can read,
which curl 7.55 and later take as `-H @file`;
[security.md](security.md#keeping-tokens-off-command-lines) shows how to
make it.
What a token may do is set when it is issued:
- **Raw ESC/POS needs `--raw`.** A job with a [`raw`](#raw) element prints
only with a token from `uberbringer token --raw`. Any other token, every
token issued before scopes existed included, gets `403` `token_scope`
with the raw elements in `details`, and keeps every other route.
- **Integration tokens are limited to modules.** A token from
`uberbringer token --modules ntfy,notify` may only call
`POST /api/v1/print/:module` and `POST /api/v1/preview/:module` for the
modules it names, `GET /api/v1/modules` and `GET /api/v1/jobs/:id`. Any
other route answers `403` `token_scope`, e.g.
`token is limited to modules ntfy, notify`. Give one of these to an
integration such as the [ntfy client](#printing-from-the-ntfy-client),
so that it cannot send printer commands.
Responses from `/healthz` and every `/api/v1` route, error responses
included, carry `Cache-Control: no-store`.
| Method | Path | Purpose |
|--------|--------------------|------------------------------------------|
| POST | `/api/v1/print` | Queue a print job |
| POST | `/api/v1/preview` | Show the lines a job prints, without printing it |
| POST | `/api/v1/print/:module` | Queue the receipt a [module](#modules) builds from its payload |
| POST | `/api/v1/preview/:module` | Show the lines that receipt prints, without printing it |
| GET | `/api/v1/modules` | List the modules |
| GET | `/api/v1/jobs/:id` | Job status |
| GET | `/healthz` | Printer, queue and subscription health (no auth) |
| GET | `/openapi.json` | This API's OpenAPI 3.1 document (no auth) |
| GET | `/` | Version information (no auth) |
[docs/swagger.json](swagger.json) is the API's OpenAPI 3.1 document:
every route, its parameters, its responses and the codes it and its
middleware answer with, and the schemas of the job and of every response.
The codes the HTTP server itself can send for any request are listed once,
in its description. It is generated from the server's route table and the
Go types behind it, and the daemon serves the copy built into it at
`GET /openapi.json`. Its enums list the canonical spellings; the server
also accepts other letter case and a few aliases, such as `centre`.
### Print a receipt
```sh
curl -X POST https://printer.example.com/api/v1/print \
-H @"$HOME/.uberbringer-auth" \
-H "Content-Type: application/json" \
-d '{
"elements": [
{"type": "rule", "style": "dark"},
{"type": "box", "fit": true, "padding": 3, "text": "!!! ACHTUNG !!!"},
{"type": "text", "text": "Überbringer", "size": 2, "bold": true, "align": "center"},
{"type": "feed"},
{"type": "text", "text": "Long paragraphs wrap at word boundaries for the paper width, so a word is never split across two lines."},
{"type": "text", "text": "Total: ", "newline": false},
{"type": "text", "text": "£12.50", "bold": true},
{"type": "qr", "data": "https://example.com", "align": "center"},
{"type": "feed", "lines": 3}
]
}'
```
The response is `202 Accepted` with a `Location` header:
```json
{"id": "job_01kbx4n6m3ex8tq0wq3r5vrzq1", "status": "queued", "source": "print", "created_at": "2026-11-29T21:04:05Z"}
```
Job IDs are [TypeIDs](https://github.com/jetify-com/typeid): UUIDv7 values
with a `job_` prefix, so they sort by creation time.
### Job status
```sh
curl -H @"$HOME/.uberbringer-auth" https://printer.example.com/api/v1/jobs/job_01kbx4n6m3ex8tq0wq3r5vrzq1
```
```json
{
"id": "job_01kbx4n6m3ex8tq0wq3r5vrzq1",
"status": "done",
"source": "module:ntfy",
"attempts": 1,
"created_at": "2026-11-29T21:04:05Z",
"started_at": "2026-11-29T21:04:05Z",
"sent_at": "2026-11-29T21:04:05Z",
"finished_at": "2026-11-29T21:04:06Z"
}
```
`status` is `queued`, `printing`, `done`, `failed` or `uncertain`. A job is
`done` once the printer has confirmed that it ran it: after each job the
daemon asks the printer for its status, which it answers only once every
byte before the question has run (with `printer.confirm = false`, `done`
means only that the job was written to the printer's connection). The
answer names no job, so before each job the daemon drops the answers
the printer still owed to earlier questions: those it sent before its
answer to a real-time question asked first, and those that come within
100 ms of each other after it. It then checks with `DLE EOT 1` that the
printer is online, and if another answer comes it sends nothing and
tries again; each job waits about 200 ms for these checks. A
[`raw`](#raw) element can still let a job read `done` before it has
printed; docs/design.md describes the one other case, where the printer,
still reporting online, pauses more than 100 ms between two answers,
which is unverified.
A failed job includes an `error` field. `uncertain` means
the receipt may have printed in full, in part or not at all: the daemon
stopped while it was sending the job, or the printer did not confirm it
within `printer.write_timeout`, as when its cover is open; its `error`
says which. Such a job is never sent again: if the paper shows it missing,
send it again. `sent_at` is when the first attempt was about to write
to the printer. A failed job with `sent_at` reached the printer, and
part of it may have printed; one without it never reached the printer.
`source` says where the job came from: `print` for `/api/v1/print`,
`module:<name>` for a [module](#modules) route, or `ntfy:<name>` for an
[ntfy subscription](ntfy.md) in the config. The last `queue.history`
finished jobs are kept.
With [`state.dir`](configuration.md#state) set, jobs are kept on disk, so
a job's status answers after a restart as before it, and a job still
waiting when the daemon stopped prints after it. A job that was being sent
to the printer when the daemon stopped reads `uncertain` from then on.
Without `state.dir`, jobs live in memory: a stop marks the waiting ones
failed, and after a restart every earlier ID answers `job_not_found`.
### Preview a receipt
`POST /api/v1/preview` takes the same body as `/api/v1/print` and validates
it the same way, but prints nothing and fetches no images. It answers `200`
with the lines the printer would print, as `text/plain; charset=utf-8`:
```sh
curl -X POST https://printer.example.com/api/v1/preview \
-H @"$HOME/.uberbringer-auth" \
-H "Content-Type: application/json" \
-d '{"elements": [{"type": "box", "fit": true, "padding": 3, "text": "!!! ACHTUNG !!!"},
{"type": "qr", "data": "https://example.com"}]}'
```
```text
┌─────────────────────┐
│ !!! ACHTUNG !!! │
└─────────────────────┘
[qr: https://example.com]
- - - - - - - partial cut - - - - - - - -
```
- The preview is read back from the bytes the job renders to, so it shows
what the printer receives: wrapping, folded characters, `?` for missing
ones, the blank lines [`printer.cut_feed`](configuration.md#printer)
feeds before a cut (3 by default) and the final cut.
- Centred and right-aligned text is indented as the printer places it,
counted in Font A columns. Text at a larger size shows each character
once.
- QR codes, barcodes, images, `raw` bytes and cuts print as placeholders
such as `[barcode ean13: 4006381333931]`, `[image 384 dots: logo.png]` and
`[raw 3 bytes]`.
With `Accept: application/json` the answer carries the styles too. For
`[{"type": "kv", "pairs": [{"key": "Total", "value": "£12.50", "bold": true}]},
{"type": "text", "text": "Thanks 🎉", "align": "center"},
{"type": "qr", "data": "https://example.com"}]`:
```json
{"columns": 42, "codepage": "cp437", "line_count": 6,
"lines": [{"kind": "text", "text": "Total ............................. £12.50",
"runs": [{"from": 0, "to": 5, "bold": true}, {"from": 36, "to": 42, "bold": true}]},
{"kind": "text", "text": " Thanks ?"},
{"kind": "qr", "text": "[qr: https://example.com]", "data": "https://example.com"},
{"kind": "text", "text": ""}, {"kind": "text", "text": ""}, {"kind": "text", "text": ""},
{"kind": "cut", "text": " - - - - - - - partial cut - - - - - - - -", "data": "partial"}],
"warnings": ["elements[1]: 1 character not in cp437 printed as ?"]}
```
| Field | Meaning |
|-------|---------|
| `columns` | Font A characters per line |
| `codepage` | The code page text is printed in |
| `line_count` | Lines the receipt prints, all copies counted: text lines, fed lines, and one for each QR code, barcode and image. [`format.max_lines`](configuration.md#format) limits it |
| `lines[].kind` | `text`, `qr`, `barcode`, `image`, `raw` or `cut` |
| `lines[].text` | The line as it prints, or the placeholder |
| `lines[].runs` | Styled parts of `text`, in characters from `from` up to `to`: `bold`, `underline` (1 or 2), `invert`, `font` (`b`), and `width` and `height` when scaled. Plain Font A text at size 1 has no run |
| `lines[].data` | QR code or barcode data, the image URL (or `base64`), the number of raw bytes, or the cut mode |
| `warnings` | Elements with characters the code page lacks, and images wider than the paper |
A job that would print more than `format.max_lines` lines answers `422`
`too_many_lines`, for example `receipt would print 2412 lines, limit is
2000`. Sent to `/api/v1/print`, the same job is accepted and then fails
when the worker renders it, before anything is sent; its `error` reads
`rendering: receipt would print 2412 lines, limit is 2000`.
### Health
`GET /healthz` returns `200` when the printer is reachable and ready, and
`503` when it is unreachable or not ready (paper out, cover open, error).
```json
{"status": "ok", "printer": {"reachable": true, "status": "ready", "online": true, "cover_open": false, "paper": "near_end"}, "queue": {"pending": 0}}
```
A printer that accepts connections but does not answer status requests is
reported as `"status": "unknown"` with HTTP `200`.
With [ntfy subscriptions](ntfy.md) configured, an
`ntfy` array lists each one, in the order of the config. The status code
still depends on the printer alone, so a subscription that cannot connect
never turns `/healthz` to `503`:
```json
"ntfy": [{"name": "home", "state": "connected", "connected_since": "2026-11-29T20:58:01Z",
"last_message_at": "2026-11-29T21:04:05Z", "printed": 12, "digested": 2, "held": 0, "last_error": ""}]
```
| Field | Meaning |
|-------|---------|
| `state` | `connecting`, `connected`, `backoff` while it waits to reconnect after a failure, or `unauthorized` when the server refused its credentials; it then tries again every five minutes |
| `connected_since` | When the current connection opened; absent while there is none |
| `last_message_at` | When the last message arrived; absent until one has |
| `printed` | Messages printed on a card of their own since the daemon started |
| `digested` | Messages held for a [digest](#digests) since the daemon started |
| `held` | Messages waiting for the next digest |
| `last_error` | Why the last connection failed, such as `HTTP 401: the server refused the credentials` or `no data for 1m45s`; empty once one opens |
Credentials, topic names and message text never appear.
Details:
- **Brief problems are re-checked.** A printer that looks not ready is read
again 750 ms later, and only a problem that is still there gives `503`.
While cutting or feeding, a printer can report a problem for a moment.
- **Timeouts.** The printer accepts one connection at a time, and a job holds
it until the printer has printed it and confirmed so (`printer.confirm`),
or, while the printer cannot print, as the job waits for it to be ready.
When that takes longer than the 3-second health check, the check gives
`503` with printer status `"timeout"`, because the printer's state is
unknown.
- **The cover flag** is only reported while the printer is offline. Epson
printers always go offline when the cover opens.
- **Paper low on the TM-T88VII.** That model does not report paper near-end
through real-time status, so `"near_end"` never appears for it; paper out
is still reported.
### Errors
Errors are JSON:
```json
{"error": "invalid job", "code": "invalid_job", "details": ["elements[2] (text): size, width and height must be 1-8"]}
```
- `code` is stable and meant for clients to match on.
- `error` is for people and may change. It never repeats the HTTP
framework's own text; for example, an unknown route answers `not found`.
- `details` lists every problem when a job fails validation (`invalid_job`),
a module route's body or payload is invalid (`invalid_payload`) or a
module builds an invalid receipt (`module_failed`), and the raw elements
a token may not print (`token_scope`). Each job problem names the element
by its path, e.g.
`elements[0].children[3] (qr): not allowed inside a box; place it after the box`,
and each problem with a module route's body names the field by its path
in the body, e.g. `payload.done[0]: index 5 is out of range`.
| Status | `code` | Meaning |
|--------|--------|---------|
| 400 | `invalid_job` | Malformed JSON, an unknown field, trailing data after the job, or invalid elements. When elements are invalid, `details` lists every problem. A `{"data": [...]}` body gets a message pointing to the [element format](#elements) |
| 400 | `invalid_payload` | A [module](#modules) route's body or payload that is not a JSON object, has an unknown field or a field of the wrong type, or is invalid, e.g. `invalid payload for module "note"`, or a body whose `copies` is outside 1–5. `details` lists every problem |
| 400 | `invalid_query` | On a module route: the request has a query string. Every input goes in the JSON body |
| 400 | `unknown_printer` | On a module route: `printer` names a printer other than `default` |
| 400 | `bad_request` | A malformed HTTP request, refused by the server itself |
| 401 | `unauthorized` | `missing bearer token`, or `invalid or expired token`. Sent with `WWW-Authenticate` |
| 403 | `token_scope` | The token does not allow the request: a token limited to modules on another route, e.g. `token is limited to modules ntfy, notify`, or a job with `raw` elements from a token issued without `--raw`, which lists them in `details`. See [tokens](#api) |
| 404 | `not_found` | Unknown route |
| 404 | `job_not_found` | Unknown, expired or malformed job ID, or, without `state.dir`, one from before a restart |
| 404 | `module_not_found` | Unknown module, e.g. `module "notx" not found` |
| 405 | `method_not_allowed` | Known route, wrong method, e.g. `DELETE /api/v1/print` with a valid token (without one, `/api/v1` answers `401` first). Sent with `Allow` |
| 408 | `request_timeout` | The request was not received in time |
| 413 | `body_too_large` | Body larger than `webserver.body_limit` |
| 422 | `too_many_lines` | From `/api/v1/preview` and `/api/v1/preview/:module`: the job would print more than `format.max_lines` lines |
| 422 | `module_failed` | A module built a receipt that fails validation, e.g. `module "note" built an invalid receipt`, with the problems in `details`. This is a bug in the module; it is logged and reported to Sentry |
| 429 | `rate_limited` | Rate limit exceeded. `Retry-After` gives the seconds to wait |
| 431 | `headers_too_large` | Request headers too large |
| 500 | `internal_error` | Unexpected failure. The cause is logged and reported to Sentry, never sent to the client |
| 501 | `not_implemented` | A request body with an unsupported transfer coding. An unknown HTTP method (e.g. `FOO /healthz`) is refused by the HTTP server itself with a plain-text `501` |
| 503 | `queue_full` | The print queue is full. Sent with `Retry-After: 10` |
| 503 | `shutting_down` | The server is shutting down |
Any other status that the HTTP layer produces itself gets the code
`http_<status>`, e.g. `http_502`. `/healthz` answers `503` with its own body,
shown under [Health](#health), not with this shape.
Validation happens before a job is queued. Images are fetched by the worker,
so a blocked or broken image URL shows up as a `failed` job, unless the image
is `optional`. Nothing is sent to the printer unless the whole receipt
rendered.
## Elements
A job is `{"elements": [...], "copies": 1}`. `copies` is 1–5, and each copy is
cut separately. A partial cut is added after the last element unless that
element is already a `cut`. Before every cut, `printer.cut_feed` blank lines
feed (3 by default), so that the last line does not sit right at the cut. Boxes, rules, key-value rows and lists are
described under [Blocks](#blocks).
### `text`
| Field | Default | Values |
|-------------|---------|--------|
| `text` | `""` | UTF-8 text. `\n` starts a new line |
| `size` | `1` | 1–8, sets width and height |
| `width`, `height` | `size` | 1–8 each, for stretched text |
| `bold` | `false` | |
| `underline` | `0` | 0, 1 (thin) or 2 (thick) |
| `invert` | `false` | white on black |
| `font` | `a` | `a`, or `b` (smaller: 56 instead of 42 columns on a TM-T88) |
| `align` | `left` | `left`, `center`, `right` |
| `newline` | `true` | `false` keeps the next element on the same line |
| `wrap` | `true` | `false` sends the text as-is and lets the printer wrap |
**Encoding.** Text is transcoded from UTF-8 to `printer.codepage`, CP437 by
default. Control characters are removed so text can never be read as printer
commands. Before that, the text is prepared for the code page:
- It is composed (Unicode NFC), so a decomposed `é` (an `e` and a combining
accent) prints as `é`.
- Characters the code page lacks fold to look-alikes: `“ ” „` print as `"`,
`‘ ’` as `'`, `–` as `-`, `—` as `--`, `…` as `...`, `•` as `·`, `→` as
`->`, `←` as `<-`, `✓ ✔` as `√` (or `x` without `√`), `×` as `x`, `€` as
`EUR` and `™` as `TM`. Where the code page has the character, as cp1252
has curly quotes and cp858 has `€`, it prints as itself.
- An emoji prints as one `?`, together with its skin tone, its variation
selector and any emoji joined to it, so `👨‍👩‍👧` is one `?`. Zero-width
spaces and joiners are removed.
- Any other character the code page lacks prints as `?`. The
[preview](#preview-a-receipt) lists the elements that have one.
**Word wrap.** The line width comes from the printer model and the character
size: on a TM-T88, 42 characters at size 1, 21 at size 2, and so on. Lines break at spaces,
and only a word longer than a whole line (a long URL, say) is split. The
renderer tracks the position across `"newline": false` elements, so mixed
sizes on one line still wrap correctly.
### `feed`
| Field | Default | Values |
|---------|---------|--------|
| `lines` | `1` | 1–255 |
### `qr`
| Field | Default | Values |
|--------------|---------|--------|
| `data` | | Required. Encoded as UTF-8, up to 7089 bytes |
| `size` | `6` | Module size in dots, 1–16. A code that could be wider than the paper prints with smaller modules. Its width is worked out as if its data were bytes, the least dense way to encode them, so a code of digits or capitals may shrink before it strictly has to |
| `correction` | `M` | `L`, `M`, `Q`, `H` |
| `align` | `left` | |
### `barcode`
| Field | Default | Values |
|-------------|---------|--------|
| `symbology` | | Required. `ean13`, `ean8`, `upca`, `upce`, `code39`, `code128` |
| `data` | | Required. Digits for EAN/UPC, where a supplied check digit is verified. `A–Z 0–9 -.$/+%` and space for CODE39. Printable ASCII for CODE128 |
| `height` | `80` | Bar height in dots, 1–255 |
| `width` | `3` | Module width, 2–6 |
| `hri` | `below` | Human-readable text: `none`, `above`, `below`, `both` |
| `align` | `left` | |
### `image`
| Field | Default | Values |
|----------|---------|--------|
| `url` | | `http`/`https` URL, or use `base64` |
| `base64` | | Image data, or a `data:image/png;base64,...` URI |
| `width` | natural | Target width in dots, up to the model's print width (512 on a TM-T88) |
| `align` | `left` | |
| `optional` | `false` | `true` prints the line `[image unavailable]`, aligned as the image, in place of an image that cannot be fetched or decoded, instead of failing the job, and shrinks an image whose `width` is wider than the paper to it |
PNG, JPEG, GIF and WebP are supported. Images wider than the paper are scaled
down to fit, and every image is dithered to black and white. URL fetches have
a timeout, a size cap and a pixel cap. URLs that resolve to loopback, private
or link-local addresses (including cloud metadata endpoints) are refused unless
`images.allow_private_networks` is true or the host is in
`images.allowed_hosts`.
### `raw`
| Field | Values |
|-------|--------|
| `hex` | ESC/POS bytes as hex, spaces allowed, e.g. `"1B 61 01"` |
Bytes that make the printer answer with a byte whose bits 4 and 7 are
clear, such as `GS r`, `GS I`, `ESC v` or `ESC u 0`, can be taken for the
printer's confirmation of the job (`printer.confirm`) when printing follows
them, so the job can read `done` before it has printed, or `uncertain`
though it printed. Answers they leave owed can do the same to the next
job: before each job the daemon drops the answers still owed to earlier
requests, but only those that come within 100 ms of each other.
The bytes are sent as given, so a job with a `raw` element prints only with
a token issued with `uberbringer token --raw`; any other token gets `403`
`token_scope`. Previewing one needs no such token.
### `cut`
| Field | Default | Values |
|--------|-----------|--------|
| `mode` | `partial` | `partial`, `full` |
## Blocks
`box`, `rule`, `kv` and `list` are blocks: they are laid out when the job
prints, from the printer model, so one job fits the TM-T88's 42 columns as
well as the TM-T20's 48. A block starts on a new line, and what follows it
starts at the left margin. These fields work on all four:
| Field | Default | Values |
|-----------|---------|--------|
| `size` | `1` | 1–3. Scales the borders and the text together: 42, 21 or 14 columns on a TM-T88 |
| `font` | `a` | `a`, or `b` (56 columns at size 1 on a TM-T88) |
| `columns` | the line | 1–255. A fixed width in characters of the block's own size and font. It is cut to the line, and a narrower block is centred |
Borders and fills are never bold, underlined or inverted. On the blocks, a
field that does not apply is an error, e.g.
`elements[3] (rule): field "pairs" does not apply to rule`. A long title,
footer or label is cut with `...` instead of failing.
### `box`
```json
{"type": "box", "style": "double", "title": "ACHTUNG", "title_style": "capped", "align": "center",
"text": "The coffee machine is being descaled.\nDo not use until 10:30."}
```
```text
╔═╡ ACHTUNG ╞════════════════════════════╗
║ The coffee machine is being descaled. ║
║ Do not use until 10:30. ║
╚════════════════════════════════════════╝
```
```json
{"type": "box", "fit": true, "padding": 3, "text": "!!! ACHTUNG !!!"}
```
```text
┌─────────────────────┐
│ !!! ACHTUNG !!! │
└─────────────────────┘
```
| Field | Default | Values |
|---------------|----------|--------|
| `text` | | The body. It wraps at word boundaries, and `\n` starts a new paragraph. Set `text` or `children`, not both |
| `children` | | The body as elements; see below |
| `style` | `single` | `single` ┌─┐, `double` ╔═╗, `double-h` ╒═╕ (double lines across, single down), `double-v` ╓─╖ (single across, double down), `ascii` +-+ |
| `title` | | Text set into the top border |
| `title_style` | `inline` | `inline` `┌─ Title ───┐`, or `capped` `╔═╡ Title ╞══╗` |
| `title_bold` | `false` | `true` prints the title bold; the border around it stays plain |
| `footer` | | Text set into the bottom border, on the right: `└──── footer ──┘` |
| `align` | `left` | Alignment of `text`, and the default for text children |
| `bold`, `underline`, `invert` | | Styles of `text`, as on a `text` element |
| `padding` | `1` | 0–3 spaces between the side borders and the body |
| `fit` | `false` | `true` shrinks the box to its widest line, title and footer included, and centres it. `columns` is then the most it may take |
**Children.** A box takes one level of these, and each prints inside the
borders:
| Type | Fields | Inside a box |
|--------|--------|--------------|
| `text` | `text`, `bold`, `underline`, `invert`, `align`, `wrap` | `size` and `font` come from the box. `"newline": false` is not allowed. `"wrap": false` splits lines at the box edge instead of at spaces |
| `feed` | `lines` | Empty lines between the borders |
| `rule` | `style` (`single` or `double`), `text`, `align`, `bold` | A divider joined to the side borders: `├──┤`, `╞══╡`, `╟──╢` or `╠══╣` to suit the box. A label reads `├── Label ───┤` |
| `kv` | `pairs`, `leader` | Key-value rows across the inside of the box |
| `list` | `items`, `bullet`, `done` | A list across the inside of the box |
`box`, `qr`, `barcode`, `image`, `raw` and `cut` cannot go inside a box;
place them after it. Children count toward the 500-element limit.
### `rule`
| Field | Default | Values |
|---------|----------|--------|
| `style` | `single` | `single` ─, `double` ═, `light` ░, `medium` ▒, `dark` ▓, `solid` █, `dashed` `- -`, `dotted` ·, `ascii` - |
| `text` | | A label set into the line |
| `align` | `center` | Where the label sits: `───── TODAY ─────`, or `── Notes ──────` at the left |
| `bold` | `false` | Prints the label bold |
### `kv`
```json
{"type": "kv", "pairs": [{"key": "Host", "value": "nas01"},
{"key": "Note", "value": "The scrub finished with 0 errors. Next scrub Sunday 03:00."},
{"key": "Used", "value": "94%", "bold": true}]}
```
```text
Host ............................... nas01
Note ... The scrub finished with 0 errors.
Next scrub Sunday 03:00.
Used ................................. 94%
```
| Field | Default | Values |
|----------|---------|--------|
| `pairs` | | Required. 1–100 rows of `{"key": "...", "value": "...", "bold": false}`. `key` is required; `bold` prints the key and the value bold |
| `leader` | `.` | The fill between key and value: `.`, `·`, `" "` (or `"space"`), `_`, `-` or `─` |
A value too long for its line wraps into the room after the key, and its
further lines are right-aligned. A key too long for the line is cut with
`...`.
### `list`
```json
{"type": "box", "title": "Shopping", "footer": "29 Nov 21:04", "children": [
{"type": "text", "text": "Milk, eggs and the good bread from the bakery on Elm St."},
{"type": "feed"},
{"type": "list", "bullet": "checkbox", "items": ["Milk", "Eggs", "Bread"], "done": [2]}
]}
```
```text
┌─ Shopping ─────────────────────────────┐
│ Milk, eggs and the good bread from the │
│ bakery on Elm St. │
│ │
│ [ ] Milk │
│ [ ] Eggs │
│ [√] Bread │
└──────────────────────── 29 Nov 21:04 ──┘
```
| Field | Default | Values |
|----------|---------|--------|
| `items` | | Required. 1–200 strings, none empty |
| `bullet` | `dot` | `dot` `· `, `dash` `- `, `number` `1. ` (right-aligned to the widest number), or `checkbox` `[ ] ` |
| `done` | | Indexes into `items`, from 0, of the ticked items of a `checkbox` list: they print as `[√] `. Each index once |
An item too long for its line wraps, and its further lines are indented to
line up under its first. A `dot` list and a `number` list:
```text
· Replace drive bay 3
· Order 2x 8 TB
1. First item that is long enough to wrap
with a hanging indent
2. Second
```
On code pages without `√` (cp850, cp858, cp1252), a done item prints as
`[x]`.
### Glyphs and code pages
CP437, the default, has every glyph the blocks draw with. Other code pages
fall back, and the [preview](#preview-a-receipt) shows the result:
| Code page | Boxes | Rules |
|-----------|-------|-------|
| `cp437` | All styles as listed | All styles |
| `cp850`, `cp858` | `double-h` and `double-v` print as `double`. A divider whose junction the page lacks switches to the other line weight, so `╞══╡` prints as `├──┤` and `╟──╢` as `╠══╣`. A capped title on double lines uses `╣ ╠` | All styles |
| `cp1252` | Every box is `ascii`, drawn with `+`, `-` and `\|`, with `=` for double dividers | `─ ═` print as `- =`, shades as `#` |
For your own text on CP437:
- **Prints:** box drawing `┌─┐│└┘├┤┬┴┼ ╔═╗║╚╝╠╣╦╩╬ ╒╓╕╖╘╙╛╜╞╟╡╢╤╥╧╨╪╫`,
shades and blocks `░▒▓█▀▄▌▐■`, and `· ∙ √ ° ± » « £ ¥ ½ ¼` and accented
Latin letters.
- **Never prints as itself:** `•` and emoji, and `► ◄ → ←` and the other
symbols CP437 keeps at byte values below 0x20, which the printer reads as
commands. `•` folds to `·` and `→ ←` to `-> <-`; the rest print as `?`. Use
`· ∙ ■ » √ °` instead.
`examples/blocks.json` prints every style, padding, size and junction on one
receipt, for checking the borders on paper. Send it as the body of
`/api/v1/print`, or look at it first with
`uberbringer preview examples/blocks.json`.
## Modules
A module takes a few plain fields, its payload, and builds the receipt from
them, so a script or a phone shortcut does not have to lay one out from
elements. `GET /api/v1/modules` lists them:
```json
[{"name": "note", "description": "Boxed note with an optional checklist"},
{"name": "notify", "description": "Notification card from title, message, priority and tags"},
{"name": "ntfy", "description": "One ntfy message object, e.g. the CLI's $NTFY_RAW"}]
```
The body of a module route holds the payload under `payload`, with the
copies to print and the printer to print them on beside it:
```sh
curl -X POST https://printer.example.com/api/v1/print/note \
-H @"$HOME/.uberbringer-auth" \
-H "Content-Type: application/json" \
-d '{"payload": {"title": "Shopping", "text": "Milk, eggs and the good bread from the bakery on Elm St.",
"items": ["Milk", "Eggs", "Bread"], "done": [2]}}'
```
| Field | Default | Values |
|-----------|-----------|--------|
| `payload` | | Required. The module's payload: a JSON object whose fields the module defines, as the sections below describe |
| `copies` | `1` | 1–5, each copy cut separately; `0` means one |
| `printer` | `default` | Reserved for a second printer: only `default` is accepted |
`POST /api/v1/print/:module` answers as `/api/v1/print` does: `202` with the
job and a `Location` header, or `503` when the queue is full or closing.
`POST /api/v1/preview/:module` takes the same body and answers as
[`/api/v1/preview`](#preview-a-receipt) does. On both routes:
- `204` with no body means the module had nothing to print.
- `400` `invalid_payload` lists every problem with the body in `details`,
each named by its path in the body, e.g. `copies: must be 1-5`. Once the
body is right, it lists every problem with the payload in the same way,
e.g. `payload.done[0]: index 5 is out of range`. The body, and the
payloads of `note` and `notify`, are decoded strictly: an unknown
field, or a field name in another case, is a problem. `ntfy` takes
ntfy's messages as they are and ignores the fields it does not know.
- `400` `unknown_printer` means `printer` names a printer other than
`default`.
- `400` `invalid_query` means the request has a query string: every input
goes in the body.
- `404` `module_not_found` names an unknown module.
- `422` `module_failed` means the module built a receipt that fails
validation. That is a bug in the module, and it is logged.
`uberbringer preview --module note payload.json` shows the receipt without
the daemon.
### `note`
A box with the text, then, when there are items, an empty line and a
checklist. The time it was built, in `format.timezone` and
`format.time_layout` ([configuration](configuration.md#format)), goes in
the bottom border. The request above prints:
```text
┌─ Shopping ─────────────────────────────┐
│ Milk, eggs and the good bread from the │
│ bakery on Elm St. │
│ │
│ [ ] Milk │
│ [ ] Eggs │
│ [√] Bread │
└──────────────────────── 29 Nov 21:04 ──┘
```
| Field | Default | Values |
|----------|----------|--------|
| `text` | | Required. The body; it wraps at word boundaries, and `\n` starts a new paragraph |
| `title` | | Set into the top border; a long title is cut with `...` |
| `items` | | Up to 200 checklist items, none empty |
| `done` | | Indexes into `items`, from 0, of the ticked items. Each index once |
| `style` | `single` | The border: `single`, `double`, `double-h` or `double-v`, as on a [`box`](#box) |
| `footer` | | Text for the bottom border in place of the time |
| `stamp` | `true` | `false` leaves the bottom border empty when there is no `footer` |
### `notify`
A [notification card](#notification-cards), for scripts, cron jobs and
phone shortcuts. The smallest payload is `{"message": "Back at 3"}`:
```text
┌─ Notification ─────────────────────────┐
│ Back at 3 │
└──────────────────────── 29 Nov 21:04 ──┘
```
```sh
curl -X POST https://printer.example.com/api/v1/print/notify \
-H @"$HOME/.uberbringer-auth" \
-H "Content-Type: application/json" \
-d '{"payload": {"title": "Disk almost full", "message": "/var is at 94% on nas01", "priority": "high",
"tags": ["warning", "nas01"], "topic": "alerts", "click": "https://grafana.lan/d/disk",
"actions": [{"label": "Open dashboard", "url": "https://grafana.lan/d/disk"}]}}'
```
```text
╔═ HIGH ═════════════════════════════════╗
║ [!] Disk almost full ║
╟────────────────────────────────────────╢
║ /var is at 94% on nas01 ║
║ ║
║ Tags: nas01 ║
╚═══════════════ alerts · 29 Nov 21:04 ══╝
[qr: https://grafana.lan/d/disk]
Open dashboard
- - - - - - - partial cut - - - - - - - -
```
| Field | Default | Values |
|------------|---------|--------|
| `message` | | Required. Up to 4096 bytes; `\n` starts a new line |
| `title` | the topic, or `Notification` | Up to 250 characters |
| `priority` | `3` | 1–5, or `min`, `low`, `default`, `high`, `max` or `urgent`, as a number or a string. It picks the [form](#notification-cards) |
| `tags` | | Up to 20 tags of up to 64 characters. Those with a [marker](#markers) print it in front of the title; the rest are listed on a `Tags:` row |
| `topic` | | Up to 64 characters, printed in the bottom border before the time |
| `click` | | An `http` or `https` URL of up to 2000 bytes, printed as a QR code |
| `actions` | | Up to 3 links, `{"label": "Open dashboard", "url": "https://..."}`, each printed as a QR code with its label: labels up to 64 characters, URLs up to 2000 bytes. A card prints at most 3 different URLs, `click` first: an action with the same URL as `click` or an earlier action prints once, with its label when the link had none, and the actions after the third different URL are left out |
| `image` | | An `http` or `https` URL of up to 2000 bytes, of an image printed after the card |
| `markdown` | `false` | `true` lays out the message as [markdown](#markdown) |
| `time` | now | When it happened: Unix seconds, or RFC 3339 such as `2026-11-29T21:04:05Z` |
A payload over a limit is `400` `invalid_payload`, e.g.
`payload.title: 300 characters, limit is 250`.
### `ntfy`
One message from [ntfy](https://ntfy.sh)'s subscribe API, exactly as ntfy
sends it, printed as a [notification card](#notification-cards). The ntfy
command line client passes such a message to a command in `$NTFY_RAW`, so
it can be posted as the payload, unchanged:
```json
{"id": "sPs71M8A2Tq9", "time": 1795986245, "event": "message", "topic": "alerts",
"title": "Disk almost full", "message": "**/var** is at *94%* on nas01",
"content_type": "text/markdown", "priority": 4, "tags": ["warning", "nas01"],
"click": "https://grafana.lan/d/disk",
"actions": [{"id": "a1", "action": "view", "label": "Open dashboard", "url": "https://grafana.lan/d/disk", "clear": false}],
"attachment": {"name": "graph.png", "type": "image/png", "size": 33848, "expires": 1796029445,
"url": "https://ntfy.example.com/file/sPs71M8A2Tq9.png"}}
```
Printed on 29 Nov 2026 at 21:04 UTC, when it was sent, before its
attachment expires:
```text
╔═ HIGH ═════════════════════════════════╗
║ [!] Disk almost full ║
╟────────────────────────────────────────╢
║ /var is at 94% on nas01 ║
║ ║
║ Tags: nas01 ║
╚═══════════════ alerts · 29 Nov 21:04 ══╝
[qr: https://grafana.lan/d/disk]
Open dashboard
[image 384 dots: sPs71M8A2Tq9.png]
- - - - - - - partial cut - - - - - - - -
```
- Fields the module does not know are ignored, so messages from newer ntfy
versions still print. A payload that is not one JSON object, or a known
field of the wrong type, is `400` `invalid_payload`.
- Events other than `message` (`open`, `keepalive`, `poll_request`,
`message_delete`, `message_clear`) and messages with a binary body
(`"encoding": "base64"`) answer `204` and print nothing. A message
without an `event` counts as a message.
- `title`, `message`, `tags`, `topic` and `time` print as on `notify`. A
missing or out-of-range `priority` is 3. `"content_type": "text/markdown"`
lays out the message as [markdown](#markdown).
- The links are `click` and the URLs of the `view` actions. `http`,
`broadcast` and `copy` actions never print, since their headers, bodies
and values can hold secrets. `icon` is ignored.
- An `attachment` that is an image prints after the card until its
`expires` passes, and after that, like any other file, is named on a
`File` row; see [links and attachments](#links-and-attachments). When the
message is only ntfy's `You received a file: <name>`, it is left out,
since the file shows on its own.
- A message that updates an earlier one, with the same `sequence_id`,
prints as it is, like any other: one message cannot tell whether it is
the first of its sequence, since a publisher may choose the sequence ID.
An [ntfy subscription](ntfy.md), which remembers
what it printed, marks such a message `(updated)`.
- A message over the [limits](#notify) of `notify` is not refused; what is
over them is cut or left out. A title, topic, tag, label or file name is
cut with `...`, and the message after 4096 bytes. Tags after the 20th are
left out, and so is a link whose URL is longer than 2000 bytes; an
attachment with such a URL is named on a `File` row instead of printed.
#### Printing from the ntfy client
The [ntfy command line client](https://docs.ntfy.sh/subscribe/cli/) can
subscribe to topics and post each message here, with no other tools. Give it
a token limited to the module, so that it cannot print anything else, in a
header file that only the user the client runs as can read. Both setups
below keep the token off command lines and out of shell history.
For your own client, with `~/.config/ntfy/client.yml`, make the file as
yourself, as [security.md](security.md#keeping-tokens-off-command-lines) shows:
```sh
mkdir -p ~/.config/ntfy
token=$(sudo uberbringer token --config /etc/uberbringer/config.toml --subject ntfy-cli --modules ntfy) &&
(umask 077; printf 'Authorization: Bearer %s\n' "$token" > ~/.config/ntfy/uberbringer-auth)
unset token
```
and add an entry like this to `~/.config/ntfy/client.yml`:
```yaml
default-host: https://ntfy.sh
default-token: tk_...
subscribe:
- topic: alerts
command: |
printf '{"payload":%s}' "$NTFY_RAW" | curl -fsS -X POST \
-H @"$HOME/.config/ntfy/uberbringer-auth" -H "Content-Type: application/json" \
--data-binary @- https://printer.example.com/api/v1/print/ntfy
if:
priority: default,high,urgent
```
For the system-wide `ntfy-client` service, with `/etc/ntfy/client.yml`, the
header file belongs to the user the service runs as, shown by
`systemctl cat ntfy-client`; here it is `ntfy`. Once the token command has
succeeded, create the file empty with that owner and mode `600`, then fill
it through `tee`, which keeps both:
```sh
token=$(sudo uberbringer token --config /etc/uberbringer/config.toml --subject ntfy-cli --modules ntfy) &&
sudo install -m 600 -o ntfy -g ntfy /dev/null /etc/ntfy/uberbringer-auth &&
printf 'Authorization: Bearer %s\n' "$token" | sudo tee /etc/ntfy/uberbringer-auth > /dev/null
unset token
```
The entry in `/etc/ntfy/client.yml` is the one above with
`-H @/etc/ntfy/uberbringer-auth` in place of the path under `$HOME`.
On Windows, `cmd.exe` breaks `%NTFY_RAW%`, so the command runs PowerShell,
with the token in the client's environment as `UBERBRINGER_TOKEN`:
```yaml
command: powershell -NoProfile -Command "Invoke-RestMethod -Method Post -Uri https://printer.example.com/api/v1/print/ntfy -Headers @{Authorization=('Bearer ' + $env:UBERBRINGER_TOKEN)} -ContentType 'application/json' -Body ([Text.Encoding]::UTF8.GetBytes('{\"payload\":' + $env:NTFY_RAW + '}'))"
```
`if:` picks the priorities that print; leave it out to print them all.
> [!WARNING]
> Anyone who knows a topic's name on the public `ntfy.sh` can publish to it,
> and so print on your printer. Use a reserved or access-controlled topic
> or your own ntfy server, or at least a long random topic name.
### Notification cards
`notify` and `ntfy` print the same card. Its form follows the priority:
| Priority | Form |
|----------|------|
| 5, `max` or `urgent` | A dark rule `URGENT`, a double box with the title row bold and inverted and a double divider, then another dark rule |
| 4, `high` | A double box headed `HIGH`, with the title row bold and a single divider |
| 3, `default` | A single box with the title, in bold, set into its top border |
| 1–2, `min` and `low` | No box: a rule with the topic and time, then the title in bold and the message |
```text
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ URGENT ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
╔════════════════════════════════════════╗
║ (!) Backup FAILED on nas01 ║
╠════════════════════════════════════════╣
║ Job nightly-offsite exited with code 2 ║
║ after 3h12m. Last good run: 2 days ║
║ ago. ║
╚══════════════ backups · 29 Nov 21:04 ══╝
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
┌─ [√] Nightly backup ───────────────────┐
│ restic: 2.1 GB added in 14m 02s, 0 │
│ errors. │
│ │
│ Tags: restic │
└────────────── backups · 29 Nov 03:12 ──┘
── backups · 29 Nov 03:12 ────────────────
Prune finished
41 snapshots kept, 3 removed.
```
The settings in [`[ntfy.format]`](configuration.md#ntfy) shape every
card: `style = "box"` gives priorities 1 and 2 the single box too, and
`style = "compact"` prints every priority without a box, with `URGENT` or
`HIGH` in front of the topic. The title is the payload's, or else the
topic, or else `Notification`; a long title is cut with `...` in a border.
The bottom border holds the topic and the time, in `format.timezone` and
`format.time_layout`.
The message prints its first `ntfy.format.max_lines` lines as written
(default 40), then `... N more lines`. Emoji are left out, apart from a few
that print as [markers](#markers): `⚠` as `[!]`, `✅` as `[√]`, `❌` as
`[x]`, `🚨` as `(!)` and `👍` as `(+1)`. Symbols a code page prints, such as
`■`, stay. A title or tag that is only emoji counts as missing.
If a card cannot be laid out, a plain receipt prints instead: the title in
bold, the message, then the topic and time. That is a bug: it is logged at
ERROR as `module printed its fallback receipt` and reported to Sentry, and
`uberbringer preview --module` prints a warning.
A card an [ntfy subscription](ntfy.md) prints for
a message that replaces one it printed before, of the same `sequence_id`,
has `(updated)` after its title, unless `ntfy.format.updates = "skip"`
leaves such messages out.
#### Digests
An ntfy subscription prints the messages it held back on one digest: those
over its rate limit as soon as the limit has room again, and those held in
quiet hours when the window ends. A row gives each message's time, its tag
markers and its title, or the first line of a message without one, or else
its topic, cut to 60 characters, in the order they arrived; the bottom
border holds the time from the first held message to the digest.
```text
┌─ ntfy digest · 6 held ─────────────────┐
│ 21:05 [!] Disk almost full │
│ 21:05 [!] Disk almost full (updated) │
│ 21:06 (!) Backup FAILED on nas01 │
│ 21:07 Watchtower │
│ 21:07 Jellyseerr │
│ 21:09 [x] grafana is DOWN │
└───────────────────────── 21:04-21:14 ──┘
```
A digest that holds a message from quiet hours is titled
`Overnight · N held`. It lists 50 messages and counts the rest on a last
row, `... and 13 more`. A digest that cannot be laid out prints as a plain
list of its rows, logged and reported like a card's fallback.
#### Markers
Up to two tags with a marker print it in front of the title, each marker
once. The other tags are listed on a `Tags: a, b` row at the end of the
card. Tags match in lower case.
| Tags | Marker |
|------|--------|
| `warning` | `[!]` |
| `rotating_light`, `fire`, `boom` | `(!)` |
| `white_check_mark`, `heavy_check_mark`, `ballot_box_with_check` | `[√]` |
| `x`, `negative_squared_cross_mark`, `no_entry`, `no_entry_sign` | `[x]` |
| `information_source` | `(i)` |
| `question` | `(?)` |
| `+1`, `thumbsup` | `(+1)` |
| `-1`, `thumbsdown` | `(-1)` |
| `loudspeaker`, `mega` | `<!>` |
| `tada` | `\o/` |
| `skull` | `x_x` |
| `hourglass` | `(...)` |
`[ntfy.markers]` in the config adds markers or changes these, and an empty
marker hides a tag: `backup = "[B]"`, `nas01 = ""`.
#### Markdown
A markdown message (`"markdown": true`, or ntfy's
`"content_type": "text/markdown"`) is laid out line by line:
| Written | Prints as |
|---------|-----------|
| `# Title`, `## Title`, `### Title` | A bold line |
| `- item`, `* item`, `+ item` | A `·` list |
| `1. item` | A numbered list |
| `> quote` | The line with `│ ` in front |
| Lines between ` ``` ` fences | As written |
| `---` | A divider across the card |
| `**bold**`, `__bold__`, `*italic*`, `_italic_`, `` `code` ``, `~~struck~~` | The text, without the marks |
| `[text](https://...)` | The text; the URL is added to the links |
| `![alt](url)` | `[image: alt]` |
A backslash keeps a mark as written: `\*` prints `*`. Marks inside a code
span or a bare URL print as written, as in `__init__.py`; a mark or
punctuation at the end of a URL is not part of it, so `**https://x.lan**`
prints the URL plain. Every other line prints as written, and a run of
empty lines as one. With
`ntfy.format.markdown = false`, markdown prints as written.
#### Links and attachments
- The links are the click URL, then the actions' URLs, then the markdown
links, each URL once and at most 3. Only `http` and `https` URLs of up to
2000 bytes print.
- With `ntfy.format.qr = "all"`, the default, each link prints after the
card as a centred QR code with its label, or else its host and path, in
the small font below it. `"first"` prints only the first as a QR code
and the others as `» label` and the URL; `"none"` prints them all as
text. On narrow paper a QR code prints with smaller modules, so that it
fits; a link longer than 500 bytes always prints as text.
- An attached PNG, JPEG, GIF or WebP image, known by its type or else its
name or URL, prints after the links, centred and 384 dots wide, or as
wide as a narrower paper. It is
fetched when the job prints, as an [`image`](#image) with `optional` set:
one that cannot be fetched prints `[image unavailable]`, and the rest of
the card prints anyway. `ntfy.format.images = false` names images on a
`File` row instead.
- Any other file, and an image whose `expires` has passed, is named on a
`File` row with its size, e.g. `File ....... report.pdf (1.4 MB)`.