How to auto-print receipts and labels from Bubble
Call the print API from a Bubble backend workflow. Do not put the API key in a page workflow the browser can see. No Bubble plugin is included.
For Bubble builders who need a shop printer without a browser dialog
Overview
Bubble page workflows run in the user's browser. That is the wrong place for a print API key, and the browser still cannot silently drive a USB printer on another computer. PrintBase does not publish a Bubble plugin.
Use a backend workflow. The API Connector call from that workflow POSTs /v1/print-jobs with the key stored in the connector's private parameters. Send a PDF receipt or raw ESC/POS or ZPL, depending on the device. The agent runs in the shop.
Idempotency-Key is the Bubble thing's unique id plus a print attempt. Backend workflows can retry when an action fails.
Integration steps
- 01
Create a backend workflow
Not a button workflow that exposes headers to the page. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 02
API Connector POST
Bearer token marked private. JSON body with printer_code and content_type.
- 03
Pass the document
Base64 from a previous step, or a file URL the agent can fetch.
- 04
Trigger the workflow when the order is paid
Do not trigger it on every autosave. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 05
Save the job id on the thing
So you can show failed versus completed. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
Node.js
// Body the Bubble API Connector should send for a receipt PDF
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': `bubble:${thingId}`,
},
body: JSON.stringify({
printer_code: Number(process.env.PRINTER_CODE),
content_type: 'pdf',
content: pdfBase64,
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
PDF path for a Bubble receipt or label
Use content_type pdf and exactly one of content (standard base64) or content_url (an http or https URL the agent can download). A private file must be fetched by your server and sent as base64, or exposed as a short-lived URL. On Windows the agent asks a PDF app to print to the named queue; if none is registered, the failure text names Adobe Reader or SumatraPDF as examples. macOS and Linux use lp.
Local agent port is not a Bubble shortcut
The agent can listen on 127.0.0.1:17891, but only for allowed origins (localhost and printbase.cloud hosts). A Bubble app origin is rejected. Use the cloud API.
Questions
Is there a Bubble plugin?
No. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Can the page workflow call the API if I hide the key?
If the call leaves the browser, the key is not hidden. Use a backend workflow.
Receipt versus label?
Thermal receipt is usually raw ESC/POS. Shipping label is PDF or ZPL. Pick content_type accordingly.
How do I reprint?
A new idempotency key. The old key will replay the original response.
Free plan: 100 jobs a month on one computer, no card.