Skip to content
Docs menu · Local printing (offline)
Guides / Local printing (offline)

Local printing (offline)

Print through a CatzPrint Station on the restaurant's own network, so tills keep printing when the internet is down. Everything printed offline is reported to the cloud when it's back: one job per idempotency key, billed and sent to your webhooks.

When to use it

  • Your tills, kitchen display or POS hub are in the same building as the printers and must keep printing tickets and receipts when the restaurant's internet connection drops.
  • You want the fastest path to paper: on the same network a job skips the round trip to the cloud.
  • You print receipt commands, templates, text or raw ESC/POS. PDFs, images and Office documents still go through the cloud (the local API answers 422 unsupported_locally).
  • It works with the desktop CatzPrint Station (Windows, macOS, Linux) and with CatzPrint Station for Android. iPhone and iPad stations print through the cloud only (iOS pauses apps in the background).

How it works

Once a desktop or Android station is paired, it also runs a small HTTPS API on the local network (port 7443 by default, base path /local/v1). It's on by default; turn it off in the station app with Allow printing from this network.

  • While online, your POS gets a local token from the cloud and the list of stations for its location, and caches both.
  • To print, it calls the station directly on the LAN. The station checks the token offline, routes the job to a printer exactly like the cloud would (routing rules, roles, role fallbacks) and prints it with the same renderer, so the paper looks identical.
  • The station writes every local job to a signed, hash-chained ledger. When it can reach CatzPrint again it uploads the ledger, and each entry becomes a normal job in the console, the API and your webhooks.

Finding a station: the cloud lists every station of a location with its URLs, certificate fingerprint and public-key pin at GET /v1/orgs/{org}/local-endpoints (API key with jobs:read or jobs:write), and stations announce themselves with mDNS (DNS-SD service _catzprint._tcp). The SDKs try configured URLs first, then the cloud list (cached), then mDNS. mDNS is never trusted on its own: it only gives the current address of a station that is already on the cloud list or whose fingerprint you pinned, and the hostname it announces is ignored.

# mDNS / DNS-SD on the restaurant network
_catzprint._tcp.local.   PTR  Front counter (CatzPrint)._catzprint._tcp.local.
Front counter (CatzPrint)._catzprint._tcp.local.
                         SRV  0 0 7443 catzprint-3f9a1c2e.local.
                         TXT  v=1 id=<station_id> org=<org_id> loc=<location_id> port=7443
                              fp=<sha-256 of the certificate, hex> tls=public
                              host=192-168-1-20.k3j9x2m4qa.local.catzprint.com
catzprint-3f9a1c2e.local. A    192.168.1.20

The station app (Local network screen) shows the station's fixed addresses with copy buttons, its certificate and its fingerprint. If your network blocks multicast, or you'd rather not depend on discovery, give the SDK those URLs. Give the station's computer a reserved IP address in your router so the URL never changes.

Security

  • Local tokens (czl1.…) are minted by the cloud for one device, bound to its location, and signed with CatzPrint's Ed25519 key. The station verifies them offline: signature, organization, expiry (at most 30 days), location and the revocation list it last downloaded. Revoking an API key or a token reaches the stations within minutes while they're online; a revoked token or device then gets 401 device_revoked.
  • Pairing code: a till without an API key can pair directly. Click Pair a device in the station app to show an 8-digit code (valid 10 minutes) next to the station's certificate fingerprint. Each network address gets 3 wrong tries and pairing closes after 20 wrong codes in all. The device sends the code to POST /local/v1/pair and gets a czd_… device token. The SDKs pair only with that fingerprint (or with a station on the cloud endpoint list). Paired devices are approved and need no API key or cloud account.
  • Device allow list: every till that talks to a station is listed in the station app, where you can revoke it. With Require approval for new devices (console → Settings → Local printing) or the station's own Only approved devices switch, a new device gets 403 device_not_approved until someone approves it.
  • HTTPS only: stations of organizations on a paid plan get their own Let's Encrypt certificate for *.<label>.local.catzprint.com, where the label is unique to the station. A name like 192-168-1-20.k3j9x2m4qa.local.catzprint.com resolves to the private address 192.168.1.20, so browsers verify the certificate normally. The SDKs also pin the certificate's public key to the public_spki_sha256 from the cloud endpoint list, so another valid CatzPrint certificate can't pose as your station. The station keeps the private key; CatzPrint only signs the request.
  • Self-signed fallback: until a public certificate is issued (or on plans without one), the station uses a stable self-signed certificate. Its SHA-256 fingerprint is in the endpoint list, the mDNS TXT record (fp) and the station app. The SDKs only accept a self-signed or IP-address URL whose fingerprint comes from the endpoint list or that you pinned; they never trust a certificate on first use, and only private addresses are used.
  • Content printed locally never leaves the restaurant: only the ledger entry (what printed where, when, a hash of the bytes and its size) is uploaded. The ledger is hash-chained and signed with a key only the station holds, so edits, gaps and rollbacks are detected and the station is flagged.

Mint a local token with an API key that has jobs:write (or as a user with the developer role or above). Tokens are bound to locations: the SDKs bind the ones they mint to the configured location, so LocationID (Go), locationId (Node, PHP), location_id (Python, Rust) is required unless you set AllLocations / allLocations / all_locations. Minting is audit-logged and limited to 60 tokens per hour per organization. The SDKs refresh the token when it has less than 7 days left.

Mint a local token
curl -X POST "https://api-v1.catzprint.com/v1/orgs/$CATZ_ORG/local-tokens" \
  -H "Authorization: Bearer $CATZ_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "device_name": "Till 3", "location_ids": ["a41e…"], "ttl_days": 30 }'

HTTP/1.1 201 Created
{
  "token": "czl1.eyJ2IjoxLCJraWQiOi….3q2-x…",
  "token_id": "0b6a…",
  "expires_at": "2026-12-07T09:15:00Z",
  "stations": [ … same objects as local-endpoints … ]
}

# Revoke it (admins, or the API key that made it):
curl -X DELETE "https://api-v1.catzprint.com/v1/orgs/$CATZ_ORG/local-tokens/0b6a…" -H "Authorization: Bearer $CATZ_KEY"

Pairing, for devices that never hold an API key:

Pair with the code from the station app
POST https://192-168-1-20.k3j9x2m4qa.local.catzprint.com:7443/local/v1/pair
Content-Type: application/json

{ "code": "48213907", "device_name": "Till 3" }

HTTP/1.1 201 Created
{ "device_id": "d_9c1e44a0b7f2d815", "token": "czd_Qm9…", "station_id": "7d0c…", "org_id": "…", "location_id": "a41e…" }

Browser tills

A web POS running in the browser can print to the station directly, too:

  • Use the station's HTTPS hostname (https://192-168-1-20.<label>.local.catzprint.com:7443), not the raw IP: browsers can't pin a fingerprint, so they need the public certificate.
  • Add your POS origin under allowed web origins in the console (Settings → Local printing), for example https://pos.example.com. Exact HTTPS origins only, up to 20. The station answers CORS preflights only for those origins.
  • Chrome asks once per POS origin for the Local Network Access permission the first time the page calls the station. Allow it on every till (or set it by policy on managed devices).
  • The station supports Private Network Access preflights: it answers Access-Control-Allow-Private-Network: true when the browser asks for it.
  • Use the browser build of the SDK, catzprint/local: no Node built-ins, works with a token from your backend or with pairing, and calls your fallback when no station answers.
TipNever put an API key in the browser. Mint the local token on your server (it's tied to one device and location and expires) and hand it to the till.

Local API reference

Base URL: one of the station's URLs, plus /local/v1. All bodies are JSON (2 MB at most). Every endpoint except info and pair needs Authorization: Bearer czl1… or Bearer czd_…. Errors use the same shape as the cloud API: {"error":{"code","message"}}.

EndpointAuthWhat it does
GET /local/v1/infoNoneStation ID, name, organization, location, version, port, TLS mode, certificate fingerprint, hostnames, addresses, whether pairing is open and the station's time.
POST /local/v1/pairPairing codeExchanges the 8-digit pairing code for a czd_… device token (rate-limited per IP).
POST /local/v1/jobs?wait=0..30Bearer tokenPrints a job. Same field names as the cloud jobs.create. Returns 201 for a new job. A key you used before (same device, or the same API key) returns 200 with that job; a key used by another caller is 409 duplicate and nothing prints. With wait it waits up to that many seconds for printed or failed.
GET /local/v1/jobs/{local_id}Bearer tokenOne local job.
GET /local/v1/jobs?idempotency_key=KBearer tokenThe job printed with that idempotency key, if it's yours (same device or API key). For a cloud job this station printed, only id, cloud_job_id and status. Otherwise 404 not_found.
GET /local/v1/statusBearer tokenCloud connection, each printer's status and paper, jobs waiting, jobs not yet reported to the cloud and the offline allowance left.

Request fields: printer_id, location_id, role, kind (commands, template, text, escpos or test), commands, template_id, data, content (text, or base64 for escpos), title, reference, copies (1–50), idempotency_key (up to 200 characters) and options. With a test token (from a cz_test_ key) every print starts with a TEST PRINT - NOT VALID banner, raw escpos is refused (422 test_raw_not_allowed) and prints count against the daily cap of 200 test prints.

POST https://192-168-1-20.k3j9x2m4qa.local.catzprint.com:7443/local/v1/jobs?wait=10
Authorization: Bearer czl1.eyJ2Ijox…
Content-Type: application/json

{
  "role": "kitchen",
  "template_id": "c2b0…",
  "data": { "order": "1042", "lines": [{ "qty": 2, "name": "Latte" }] },
  "reference": "Order 1042",
  "idempotency_key": "order-1042-kitchen"
}
  • Routing is the same as in the cloud, limited to this station's printers: printer_id must be one of them, a location_id other than the station's is 403 forbidden_location, then routing rules, then role and role fallback.
  • status of a local job is queued, printing, printed or failed (with error_code). printed_locally is always true, via is "local", live is false for test tokens, and cloud_job_id is filled in once the job is reported.
  • A device only sees its own jobs; other job IDs answer 404.
  • If the station stops while a job is printing, the job is recorded as printed ("Interrupted; may have printed") and billed; jobs that were still queued are recorded as failed ("Station restarted").

Errors

The SDK modes treat errors in two groups. If the station answered, the error is about the job or the printer and is returned to you: printing somewhere else wouldn't help and could print twice. If no station answered, it's station unreachable and the fallback modes try the cloud.

CodeHTTPMeaninglocal_first falls back to the cloud
unauthenticated401Missing or malformed token.Yes, without a new token
token_expired401The local token expired. The SDKs mint a new one (at most once per 10 minutes).After one new token (at most once per 10 minutes)
device_revoked401The device or token was revoked. Don't retry with it: the SDKs never mint a new token for it.Yes, without a new token
device_not_approved403New device waiting for approval in the station app.No, returned to you
forbidden_location403The token doesn't cover this station's location, or location_id is another location.No, returned to you
invalid400 / 422A field is wrong (see message).No, returned to you
unsupported_locally422PDF, image, document or file_id jobs: send them through the cloud.No, returned to you
test_raw_not_allowed422Test tokens can't send raw ESC/POS. Use commands, a template or text, or a live token.No, returned to you
no_printer422No enabled printer on this station matches the printer, rule or role (and fallback).No, returned to you
not_found404No such local job or idempotency key.No, returned to you
duplicate409The idempotency key was already used by another device or API key. Nothing printed.No, returned to you
offline_allowance_exhausted402The station has been offline too long or has used its offline prints. Connect it to the internet.No, returned to you
test_limit402The station can't print more test jobs offline (daily test cap, or a personal account). Connect it, or use a live token.No, returned to you
printer_offline503The routed printer is offline. Returned before the job is accepted: nothing is recorded or counted.No, returned to you
out_of_paper503The routed printer is out of paper (same rules as printer_offline).No, returned to you
cover_open503The printer's cover is open.No, returned to you
printer_error503The printer reports an error.No, returned to you
local_disabled503Printing from the network is turned off in the station app.Yes
rate_limited429Too many requests from this device.No, returned to you
Station unreachableno answer, TLS error, timeout, 502, 504No station answered. Go: errors.Is(err, catzprint.ErrStationUnreachable) (a *StationUnreachableError with the URLs tried). Node: StationUnreachableError.Yes
TipIf a printer fails while it's printing, the request still succeeds and the job ends as failed with error_code (for example out_of_paper). It's recorded and reported, but failed jobs are never charged.

SDK modes

All five official SDKs (Node.js/TypeScript, Python, PHP, Go and Rust, version 2.2.0 and later) have four modes, configured once on the client. Results get via ("local" or "cloud") and printed_locally.

ModeWhat it does
cloudThe default. Unchanged: every job goes through the cloud.
localStation only. If no station answers you get station unreachable.
local_firstTries the stations (configured URLs, then the cloud list, then mDNS) and falls back to the cloud only when no station answers or it replies 503 local_disabled. Best for restaurants.
cloud_firstSends through the cloud; on a network error, timeout or 5xx it prints locally with the same idempotency key. A 4xx from the cloud is returned as is.
client, err := catzprint.NewClient(
	catzprint.WithAPIKey(os.Getenv("CATZPRINT_API_KEY")),
	catzprint.WithLocal(catzprint.LocalConfig{
		Mode:       catzprint.ModeLocalFirst, // or ModeCloud, ModeLocal, ModeCloudFirst
		LocationID: locationID,              // required for minted tokens (or AllLocations: true)
		Discover:   true,                    // cloud endpoint list + mDNS
		DeviceName: "Till 3",
		TokenStore: catzprint.NewFileTokenStore("/var/lib/pos/catzprint-local.json"), // 0600
	}),
)
if err != nil {
	log.Fatal(err)
}
defer client.Close()

job, err := client.PrintTemplate(ctx, kitchenTemplateID, map[string]any{"table": "12", "items": items},
	catzprint.JobParams{Role: "kitchen", IdempotencyKey: "order-1042-kitchen-r1"})
var sue *catzprint.StationUnreachableError
switch {
case err == nil:
	log.Printf("job %s via %s, printed locally: %v", job.ID, job.Via, job.PrintedLocally)
case catzprint.IsPrinterOffline(err), catzprint.IsOutOfPaper(err):
	showStaff(err) // the station answered: not sent anywhere else; retry later with the same key
case errors.As(err, &sue):
	log.Printf("tried %v, cloud: %v", sue.URLs(), sue.CloudErr)
default:
	log.Print(err)
}
  • The fallback modes need an idempotency key so a job can never print twice. If you don't pass one, the SDK sets sdk-<uuid>; pass your own stable key (order-1042-kitchen-r1) so retries after a crash are safe too.
  • Modes that mint tokens need LocationID / locationId / location_id, or AllLocations: true / allLocations: true / all_locations=True for a token valid at every location the API key may use.
  • On 401 token_expired the SDK mints a fresh token once (at most once per 10 minutes per device) and retries. device_revoked is never answered with a new token. When a station still refuses the token, local_first uses the cloud and local returns the error.
  • Tokens are kept in a token store (Go: NewFileTokenStore, file mode 0600; Node: FileTokenStore; browser: you pass the token or pair) and refreshed when less than 7 days are left. The station list is refreshed hourly while online.
  • Pairing (needs the code and the fingerprint from the station app, or a station on the cloud list): see the examples below. A client in local mode with the paired czd_… token needs no API key.
  • Timeouts: 3 seconds to connect to a station, 15 seconds per local request (configurable).
  • Helpers: Local.Status, Local.Discover, Local.Info, Local.Pair, Local.Token, LocalTokens.Create / Revoke, LocalEndpoints.List; error helpers IsPrinterOffline, IsOutOfPaper, IsCoverOpen, IsOfflineAllowanceExhausted, IsStationUnreachable (Node: isPrinterOffline and so on).

PHP usually runs once per web request, so the PHP SDK has no background work: it renews the token and station list lazily, after a station answered (a failed renewal waits 5 minutes), or from a cron job with 'autoRefresh' => false and $catz->local->refresh(). Use a FileTokenStore (or your own store, e.g. Redis) outside the web root: the default in-memory store lasts one request, so every request would mint a new token. Pass orgId to skip a key lookup per request. mDNS needs ext-sockets; without it the SDK uses the cloud list and your URLs. Local printing needs ext-openssl.

Pair a till that has no API key, with the 8-digit code and the fingerprint shown in the station app:

p, err := client.Local.Pair(ctx, "https://192.168.1.20:7443", "48213907", "Till 3",
	catzprint.PairFingerprint("5f1c…e09a"))

till, err := catzprint.NewClient(catzprint.WithLocal(catzprint.LocalConfig{ // no API key
	Mode:         catzprint.ModeLocal,
	StationURLs:  []string{"https://192.168.1.20:7443"},
	Fingerprints: map[string]string{"192.168.1.20": "5f1c…e09a"},
	Token:        p.Token, // czd_…
}))

Idempotency and reconciliation

  • One job per idempotency key. The station remembers every key it printed for 30 days, local or cloud: a repeat with a known key never prints again, and a cloud job with a key that already printed locally isn't printed again (it's reported as printed locally, with one job.printed webhook).
  • When the ledger is uploaded, each entry becomes a job. No job with that key yet: a new job with source: "local" and printed_locally: true.
  • A job with that key exists, hasn't finished (or was for this station), is live or test like the entry, is at most 35 days old and wasn't merged before: it's merged. It's marked printed with printed_locally: true and cloud delivery is cancelled. It isn't charged again, except for copies beyond the job's own, which are billed on the same job.
  • Otherwise (for example the job already printed somewhere else) the local print is recorded as a new job with duplicate_of set to that job and billed as a separate print. The console shows it as a duplicate.
  • job.printed and job.failed webhooks are sent for every created, merged or duplicate job. The job includes printed_locally, local_device, duplicate_of and offline (true when the station had no cloud connection when it printed). Webhooks arrive when the station reconnects, not when the paper came out: use printed_at for the time.
  • The content is never uploaded (card slips and customer data stay in the restaurant), so local jobs can't be previewed or reprinted from the console.
  • Unpairing or removing a station first uploads what it hasn't reported yet; anything it couldn't send is kept on the computer and uploaded after the station is paired again in the same organization.
  • Tampering is detected: if an upload doesn't match the station's chain (edits, gaps, rollbacks), the station is flagged, admins are notified and offline printing stops until an admin resets the ledger on the station's page (at most 3 times in 30 days; the next allowance is smaller for 7 days).
Webhook for a job printed offline
{
  "id": "0b8f6c1e-…",
  "type": "job.printed",
  "org_id": "9b2f…",
  "created_at": "2026-11-07T21:30:05Z",
  "data": {
    "job": {
      "id": "6f1c2a7e-…",
      "source": "local",
      "status": "printed",
      "reference": "Order 1042",
      "printed_locally": true,
      "local_device": "Till 3",
      "duplicate_of": null,
      "offline": true,
      "printed_at": "2026-11-07T19:02:12.010Z",
      …
    }
  }
}

To reconcile with your own records, export the jobs printed locally with GET /v1/orgs/{org}/local-jobs/export?since=…&format=csv|json (API key with jobs:read, or developer role and above; the last 30 days by default, up to 10,000 rows, X-More: true when there are more). It lists the idempotency key, local ID, printed time, copies and extra copies, station, device, offline, live and how each job was billed.

Export local jobs
curl "https://api-v1.catzprint.com/v1/orgs/$CATZ_ORG/local-jobs/export?since=2026-11-01T00:00:00Z&format=csv" \
  -H "Authorization: Bearer $CATZ_KEY"      # jobs:read; format=json is the default

job_id,idempotency_key,local_id,status,created_at,printed_at,copies,extra_copies,station_id,station_name,location_id,local_device,offline,live,billed_as,duplicate_of,reference
6f1c2a7e-…,order-1042-kitchen-r1,lj_4f2a9c0b1d3e5f67,printed,2026-11-07T19:02:11Z,2026-11-07T19:02:12Z,1,0,7d0c…,Front counter,a41e…,Till 3,true,true,plan,,Order 1042

Billing and the offline allowance

  • Offline prints are billed when the cloud records them (in that month), like any print: free, included and bought prints first, then print debt, or as metered usage on paid business plans. Failed jobs are never charged.
  • Test-token prints carry the TEST PRINT - NOT VALID banner and count against the daily cap of 200 test prints; past it they're billed like live prints. Personal accounts can't print test jobs locally (402 test_limit).
  • Each station holds an offline allowance signed by the cloud, valid for 7 days. The organization's offline budget (prints left this month plus a small overdraft, or a fixed cap on metered business plans) is shared across its desktop and Android stations that print locally: each gets a share. Print debt uses up the overdraft, so while you owe prints there's no further offline overdraft.
  • Prints past your plan's remaining prints still print within the allowance and settle later as print debt (or metered usage on business plans).
  • Every time the station uploads its ledger it gets a new allowance. If it has been offline too long, has used its share or has too many unreported jobs, it refuses new local jobs with 402 offline_allowance_exhausted until it's back online. The station's page in the console shows the allowance, unsynced jobs and last upload.

Role fallbacks

Role fallbacks are set per location in the console (Locations → a location → Printer role fallbacks, admins), or with role_fallbacks in the locations API, for example {"bar": "kitchen"}. Up to 20 pairs, role names of 1–40 characters, a role can't fall back to itself. The cloud and the stations use the same rules:

  • A healthy printer with the role asked for (enabled, station enabled and connected, status ready, busy or paper_low) is used first.
  • Otherwise a healthy printer with the fallback role. The job's status detail says "Sent to kitchen printer: no bar printer available".
  • Otherwise any printer with the role (the job waits for it), then any printer with the fallback role, else no_printer.
  • Only one step: the fallback's own fallback isn't followed. Routing rules still come first.
TipOn a station the same rules apply to its own printers, using the printers' live status. That's how a bar ticket still prints in the kitchen when the bar printer is out of paper during an outage.