How to auto-print Shopify shipping labels
Print a Shopify shipping-label PDF on a local thermal printer from your own app. No PrintBase Shopify plugin — one API call after the label exists.
For Shopify sellers and the developers automating a packing bench
Overview
Shopify can buy a carrier label, but it will not silently drive an arbitrary thermal printer on the packing bench. The label you care about is almost always a 4 by 6 inch PDF. PrintBase does not provide a Shopify app, theme block, or Flow connector. Your own backend receives the order event and posts that PDF.
Trigger the print when the label file actually exists, usually on fulfillments/create or when your shipping app writes the label URL back to the order. If that URL is publicly fetchable over HTTPS, send it as content_url and let the agent download it. If Shopify or the carrier requires a session, download the PDF in your app and send base64 content instead. The API key stays in that backend, never in a theme or checkout extension.
Point printer_code at the queue installed on the packing computer. Build the Idempotency-Key from the Shopify order id and the fulfillment id so a webhook retry does not peel a second label. Generate a new key only when a person asks for a reprint.
Integration steps
- 01
Install the agent on the packing PC
Install the PrintBase agent on the Windows, macOS, or Linux computer that already has the label printer. GET /v1/printers and store the numeric code field for that queue as printer_code.
- 02
Catch the fulfillment, not the page view
Subscribe to the Shopify webhook that fires once the label PDF exists. Ignore storefront traffic. Verify the webhook HMAC in your app before printing.
- 03
Choose URL or base64
Public HTTPS label files can be content_url. Files behind Shopify auth must be downloaded by your server and placed in content as standard base64.
- 04
Post the job with a stable key
POST /v1/print-jobs with content_type pdf, copies 1, and an Idempotency-Key of order id plus fulfillment id. The same key and body replay the original job instead of printing twice.
- 05
Confirm before you mark the order packed
Read GET /v1/print-jobs/{id} until completed, or subscribe to the paid-plan webhook print_job.completed. Do not treat HTTP 201 as paper on the bench.
Node.js
// Shopify fulfillment webhook: print the 4x6 label 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': idempotencyKey,
},
body: JSON.stringify({
printer_code: Number(process.env.PRINTER_CODE),
content_type: 'pdf',
content_url: labelPdfUrl,
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 4×6 Shopify 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.
4×6 inch media
Size the PDF to 4 by 6 inches (about 100 by 150 mm) before you send it. A letter-size PDF scaled by the driver will shrink the barcode. The agent does not crop or resize the file.
How you know it printed
Create returns id and status queued. The job then moves queued, dispatched, printing, completed. Failures use reason codes such as AGENT_OFFLINE, PRINTER_OFFLINE, DOWNLOAD_FAILED, PRINT_ERROR, and INVALID_CONTENT. Poll GET /v1/print-jobs/{id}. Webhooks exist on paid plans only, and only for print_job.completed and print_job.failed.
Questions
Does PrintBase have a Shopify app?
No. There is no Shopify plugin in this product. An app you run, a custom app backend, or an HTTP call you control posts the label to the API.
Can the Shopify storefront call the API?
Do not put the API key in theme code. The browser would expose it. Call PrintBase from the server that handles the webhook.
What if Shopify retries the webhook?
Reuse one Idempotency-Key per label. A replay with the same key and body returns the original job. A different body under that key returns HTTP 409.
The label URL returns 403 to the agent.
content_url must be reachable by the agent without your user's cookies. Download it yourself and send base64 content, or sign a short-lived URL.
Which printer_code do I use?
GET /v1/printers and use the code of the queue on the packing computer. The create call names that value printer_code. The legacy printer_id field still works.
Free plan: 100 jobs a month on one computer, no card.