Add printing to a multi-tenant SaaS
Each customer site prints to its own printer_code. The API key stays on your server. Enterprise accounts can isolate customers in child organizations.
For SaaS vendors adding print for every customer
Overview
Your customers will not open a port for you. They install an agent and tell you the printer code, or you create a child organization and an API key per customer if you are on Enterprise. The print call still comes from your cloud, not from their browser.
Store printer_code on the tenant. Refuse to print if it is missing. Do not fall back to another tenant's printer. That is the whole safety property.
Enterprise endpoints can create an organization and an API key for it: POST /v1/enterprise/orgs and POST /v1/enterprise/orgs/{id}/api-keys. That requires an Enterprise account and the enterprise:write scope. A single organization with many printer codes is enough when tenants may share a vendor account.
Integration steps
- 01
Decide the printer before the click
Map the station, store, or line to a printer_code from GET /v1/printers. Do not ask the operator to pick a dialog.
- 02
Create the document in your system
PDF for driver printers, raw ZPL or ESC/POS when the device speaks that language.
- 03
POST when the business event happens
Pack, pay, check-in, or scan. Not on every autosave. Use the business id as Idempotency-Key.
- 04
Show the job result where the work is
queued is not done. Surface AGENT_OFFLINE and PRINT_ERROR to the person at the bench.
Node.js
// Tenant job using that tenant's printer_code
const res = await fetch('https://api.printbase.cloud/v1/print-jobs', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body: JSON.stringify({
printer_code: Number(process.env.PRINTER_CODE),
content_type: 'pdf',
content: pdf.toString('base64'),
copies: 1,
}),
});
if (!res.ok) throw new Error(`PrintBase ${res.status}: ${await res.text()}`);
const job = await res.json();
// { id: "job_abc", status: "queued" }
Details for this setup
Isolation
One printer_code per site, checked on the server. Enterprise child orgs when you need separate keys and job lists.
Onboarding
The customer installs the agent and you read GET /v1/printers with their key, or with yours if they share the org.
Questions
Do customers get the master API key?
No. Give them a key for their org, or no key at all if only your server prints.
Can tenant A see tenant B's jobs?
Not across organizations. Inside one organization, anyone with print:read on that org can. Split orgs if that is too wide.
Usage? in this setup
GET /v1/enterprise/usage summarizes child orgs for Enterprise accounts. It is not a per-tenant invoice by itself.
Free plan per customer?
The free plan is 100 jobs on one computer for that organization. Do not promise it as a pooled unlimited tier.
Free plan: 100 jobs a month on one computer, no card.