How to know a print job actually printed
HTTP 201 means the job was queued. Completed means the agent reported success. Poll the job, or use a paid-plan webhook for the terminal events.
For Developers who treated HTTP 200 as paper
This page in another language: 中文
Overview
Create returns id and status queued. The documented path is queued, then dispatched, printing, and completed. A terminal failure carries a reason code: AGENT_OFFLINE, PRINTER_OFFLINE, DOWNLOAD_FAILED, PRINT_ERROR, or INVALID_CONTENT. The Windows spooler can also surface codes such as PAPER_OUT or HEAD_OPEN when it reports them.
Poll GET /v1/print-jobs/{id}. The body includes status and printer_code. It does not include the original base64 content. Paid plans can register a webhook for print_job.completed and print_job.failed only. Creating a webhook on the free plan returns 403 PLAN_LIMIT_EXCEEDED.
The webhook signature is X-PrintBase-Signature, an HMAC of the timestamp and the raw body. That is how you know the callback is yours. It is not sent for intermediate statuses.
Integration steps
- 01
Store the job id
Write it on the order when you receive the 201. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 02
Poll or subscribe
Free plan: GET. Paid plan: webhook for the two terminal events, plus poll as a backstop.
- 03
Branch on status
completed is the success you can show. A reason code is the failure you can show.
- 04
Do not reprint on every poll
Reprint is a new POST with a new key. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
Node.js — read job status
// Create, then read the job
const created = 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': jobKey,
},
body: JSON.stringify({
printer_code: Number(process.env.PRINTER_CODE),
content_type: 'raw',
content: Buffer.from(payload).toString('base64'),
copies: 1,
}),
}).then(async (res) => {
if (!res.ok) throw new Error(await res.text());
return res.json();
});
const status = await fetch(`https://api.printbase.cloud/v1/print-jobs/${created.id}`, {
headers: { Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}` },
}).then((res) => res.json());
// status.status moves queued -> dispatched -> printing -> completed
Details for this setup
Webhook events
Only print_job.completed and print_job.failed. Not queued, not dispatched. The agent prints only what you send; it does not fetch the document from the platform for you.
Signature
HMAC-SHA256 over timestamp.rawBody using the endpoint secret. Verify the raw body, not re-serialized JSON.
Questions
Is queued the same as printed?
No. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Does completed mean the customer took the paper?
It means the agent reported the print finished. A person can still lose the page. It does not mean a sensor saw a hand.
Free webhooks?
No. 403 PLAN_LIMIT_EXCEEDED. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Idempotent create and status?
A replay returns the original job. Poll that same id. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Free plan: 100 jobs a month on one computer, no card.