Skip to content

Concepts

Everything in Printsluis belongs to an organization: its agents, printers, aliases, API keys, jobs and settings. An API key acts only in its own organization; another organization’s printers and jobs don’t exist for it.

People sign in to the portal at app.printsluis.nl as members of an organization:

Role Can
Admin Pair and disable agents, manage printers and aliases, API keys, webhooks, members and settings, test-print and reprint
Viewer See jobs, agents and printers and their health

Applications authenticate with an API key in the Authorization header:

Authorization: Bearer pgw_...

Admins create keys on the portal’s API keys page. A key is shown once, when it’s created; Printsluis keeps only a hash of it. Revoke a key there when you no longer need it, or when it may have leaked. Use one key per application, so you can revoke one without touching the others.

Each key has scopes: give it only what its application needs.

Scope Allows
print:create Submitting and cancelling jobs, test prints, and fetching encryption keys
print:read Reading and searching jobs
printers:read Listing printers and aliases, and printer alerts
agents:read Listing agents and their health, and agent alerts
mcp:print Printing through the MCP server, on top of print:create. Never selected by default

A request without a valid key gets 401; a key without the scope it needs gets 403.

A software vendor that runs printing for many customers can have a partner key, with the scopes organizations:read and organizations:write. It creates and manages customer organizations through the API (/v1/organizations), creates pairing codes for their agents, and acts inside one customer organization by sending its ID in the X-Organization-Id header, so the partner needs no key per customer. See the API reference and the .NET SDK.

The Printsluis Agent is a Windows service on a machine in the customer’s network. It collects jobs from the API over outbound HTTPS and prints them on the printers it can reach. Nothing connects to the agent.

  • Pairing. An admin creates a pairing code in the portal (Agents → Pair an agent). The code works once and expires after 15 minutes. Pairing creates a key on the machine that cannot be copied elsewhere; the agent uses it to authenticate from then on.
  • Health. The portal and GET /v1/agents show whether an agent is online, when it was last in contact, and its version. An agent out of contact for 3 minutes raises an alert, by email and as a webhook.
  • Updates. Agents installed with the MSI update themselves. See Installing the agent.
  • Identity fingerprint. Each agent has a fingerprint such as SHA256:A5BYxvLAy0ksUzsKTRTvd8wPeKvMztUofYShogEc+4E, which you can use to pin it for end-to-end encryption.

A printer is added in the portal, on one of the agents that can reach it:

  • Network printer: direct TCP on port 9100. No driver needed. For Zebra printers the agent reads the printer’s own status.
  • Windows printer: a printer installed on the agent’s machine, by USB or network, printed through its Windows driver.

Its printer type sets what it accepts: Zebra label printer (zpl), office printer (pdf, Windows printers only) or generic printer (raw).

Every printer has a stable printer ID. Store it as a user’s or a location’s preferred printer: it doesn’t change when the agent restarts, and re-adding the same connection on the same agent gives back the same ID. GET /v1/printers lists the printers with their name, location, formats and availability, for a printer choice in your application. The portal shows the ID in the printer’s side panel.

Availability is what the printer last reported: ready, needsAttention (paper out, head open, paused…), unreachable, or unknown for a printer that cannot report its status.

When one printer can be reached from more than one agent, add a route for each extra agent (in the printer’s side panel, Add route). It stays one printer with one ID. Every agent with a route prints its jobs, still one at a time, so the printer keeps printing while one agent is down.

An alias is an organization-wide name for a printer, such as labels or office. It gives applications a default without knowing printer IDs, and lets an admin move the default to another printer without changing any application. Alias names are 1 to 63 lowercase letters, digits or hyphens, starting with a letter or digit.

A job’s target is one of:

Target Prints on
{ "printerId": "…" } That printer
{ "printerId": "…", "fallbackAlias": "labels" } That printer; the alias’s printer if that printer is disabled, removed or doesn’t accept the format
{ "alias": "labels" } The printer the alias points to

The target is resolved when the job is submitted, and the job keeps that printer. An offline printer or agent does not trigger the fallback: the job waits in the queue until the printer is back or the job expires. When nothing resolves, the API answers 422 printer_unavailable. resolvedVia on the job tells you whether it went by printerId, alias or fallbackAlias.

queued → assigned → downloaded → submittedToPrinter → succeeded
│ │ │ │
│ └────────────┴── problem before the printer got data ──→ queued (next attempt) or failed
│ └── outcome unknown ──→ indeterminate
├─→ cancelled (while queued or assigned)
└─→ expired (not claimed before its time-to-live passed)
Status Meaning
queued Accepted and waiting for an agent
assigned An agent claimed it
downloaded The agent has the document
submittedToPrinter The agent started sending data to the printer: the point of no return
succeeded Final. The printer or the Windows spooler accepted the whole job without an error it could detect
failed Final. The job failed, or ran out of attempts before it reached the printer. failureCode says why
cancelled Final. Cancelled before it was handed to the printer
expired Final. No agent claimed it before its time-to-live passed
indeterminate The data may have reached the printer, but the outcome is unknown. Never retried automatically

What succeeded means. For a Zebra printer on TCP, the printer answered a status query sent behind the job, so it read the whole job, and its status after the job shows no error. For a Windows printer, the job left the Windows print queue without an error. It does not prove that paper came out.

Further rules:

  • One job at a time per printer, in order. Different printers print in parallel.
  • A printer that needs attention holds its jobs. When a Zebra printer on TCP reports paper out, head open or paused, the job stays queued without using an attempt, and prints when the printer is ready.
  • Retries happen only before the point of no return. A refused connection or an agent that stops before sending puts the job back in the queue for its next attempt. Admins set the number of attempts (1 to 10, default 3) in the portal’s settings.
  • Time-to-live. A job that waits longer than its time-to-live expires instead of printing late. Set it per job with ttlSeconds (60 seconds to 24 hours); the default is the organization’s setting, 1 hour unless an admin changed it.
  • Cancelling (POST /v1/print-jobs/{id}/cancel) works while a job is queued or assigned. After that it answers 409 job_not_cancellable.
  • Failure codes on a failed or indeterminate job are stable codes, such as printer_unreachable, zpl_command_blocked, pdf_preparation_failed or decryption_failed, with a description for people in failureMessage.

A label printed twice can be an incident: two shipments, two prescriptions. So Printsluis prints at most once by default.

Once the agent has started sending a job to the printer, it can no longer tell for sure whether a problem happened before or after the printer printed it: a connection that drops, an agent that restarts, a Windows queue that holds the job. Printsluis then does not guess and does not retry. The job becomes indeterminate, shown as Outcome unknown in the portal.

What to do with an indeterminate job:

  1. Check the printer: did the label come out?
  2. If not, print it again. An admin can Reprint the job from the portal for 24 hours; after that, the document is deleted and your application has to submit it again (with a new idempotency key).

An organization that prefers a possible duplicate over a missing label can change this in the portal’s settings, under When it’s unknown whether a label printed: Print it again retries until the attempts run out.

Networks fail. If your application doesn’t know whether a submission arrived, it should be able to send it again without printing twice. That is what the Idempotency-Key header is for:

POST /v1/print-jobs
Idempotency-Key: order-1042-label
  • The same key with the same request returns the existing job with 200 OK, instead of 202 Accepted for a new job. Nothing prints again.
  • The same key with a different request fails with 409 idempotency_key_reused.
  • A key stays taken for as long as its job exists, until retention removes it, not just for a day.
  • Keys are at most 128 characters. Derive them from what you print, such as order-{id}-label, not from a random value per attempt.

For an end-to-end encrypted document, the comparison leaves out the encrypted content, because encrypting the same document twice gives different bytes. A retry with the same key still returns the original job.

Always send an idempotency key when your code, or an HTTP retry policy, may retry a submission.

Format For Limit
zpl Zebra label printers. Sent to the printer unchanged 1 MiB
pdf Office, receipt and label printers with a Windows driver 25 MiB, 250 pages
raw Other printer languages, sent unchanged. Off until an admin allows raw printer data in the settings 1 MiB

The document goes in document.content, base64-encoded, and the printer must accept the format. Otherwise the job is refused, or goes to the fallback alias.

  • ZPL that reconfigures a printer is blocked. The agent refuses ZPL that changes the printer’s settings, such as ^JU, network and wireless settings, passwords, and downloading or deleting stored objects. The job fails with zpl_command_blocked.
  • Copies (1 to 100) are on the job. For ZPL, the agent sends the label that many times; it doesn’t change ^PQ in your ZPL.
  • PDF print options go in printOptions: paperSize (a4, a3, letter, legal) or paperName (a size by the driver’s name, such as 72mm x Receipt), orientation, scaling (fit or actualSize), duplex, color, collate, firstPage and lastPage, and placement (center or topLeft). Options left out use the printer’s defaults. Password-protected PDFs and interactive forms are refused; flatten forms first. Selected pages times copies is at most 2,500. See the API reference for every field.

Errors are application/problem+json with a stable code to branch on, for example:

{
"title": "No enabled printer that accepts this format matches the target.",
"status": 422,
"code": "printer_unavailable"
}

The title is for people and may change; the code doesn’t. Codes you are likely to meet:

Status Code Meaning
400 invalid_document, invalid_target, invalid_metadata, … The request is not valid
403 plan_limit The organization’s plan doesn’t allow this, such as PDF printing or more prints this month
403 organization_suspended The organization takes no new jobs
404 print_job_not_found, printer_not_found Not found in this organization
409 idempotency_key_reused The idempotency key belongs to a different request
409 job_not_cancellable The job is past the point where it can be cancelled
422 printer_unavailable No enabled printer that accepts the format matches the target
422 raw_printing_not_allowed The organization doesn’t allow raw printer data
422 encryption_required, encryption_unavailable, encryption_keys_stale See End-to-end encryption
429 Too many requests; wait and retry

New codes may be added. Treat a code you don’t know by its HTTP status.

What Limit
Requests At least 300 a minute per API key; above that, you may get 429
Document size ZPL and raw 1 MiB, PDF 25 MiB (an admin can set a lower limit)
PDF 250 pages; selected pages times copies at most 2,500
Copies 1 to 100
externalReference 128 characters
metadata 20 entries; keys 1 to 64 characters, values up to 256
Idempotency-Key 128 characters
ttlSeconds 60 to 86,400 (24 hours)
Job search limit 1 to 100, default 50
Job history Kept as long as the organization’s retention setting: 7 to 365 days, default 90
  • Documents are stored encrypted, deleted as soon as a job is final, and never written to logs. The document of an indeterminate job is kept 24 hours so it can be reprinted.
  • externalReference and metadata are stored as plain text, kept for the job’s whole retention period, and searchable. Never put personal data in them; use your own IDs.
  • Printsluis is hosted in Amsterdam, in the EU.