PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/Guides/Platform printing integrations

How to auto-print receipts from Supabase or Firebase

Print a receipt from a Supabase database webhook or a Firebase function. The function holds the API key. No native plugin is included.

For SaaS developers whose orders land in Supabase or Firebase

Overview

A row insert is not a printer. Supabase database webhooks and Firebase functions are the moment you have an order and a place to keep a secret. PrintBase does not ship a Supabase or Firebase extension.

The function reads the new order, builds ESC/POS or a PDF, and POSTs /v1/print-jobs to the printer_code for that tenant or store. Multi-tenant apps should store printer_code on the tenant row and refuse to print if it is missing.

Idempotency-Key is the order primary key. Webhooks retry. Do not mint a random UUID per attempt or you will print duplicates.

Integration steps

  1. 01

    Trigger on insert or on a status column

    Print when the order is payable, not when a draft row is created.

  2. 02

    Read printer_code from the tenant

    The client must not send an arbitrary code unless you authorize it. Prefer the value stored on the server.

  3. 03

    Build the receipt in the function

    ESC/POS raw or PDF. Encode text for the printer. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.

  4. 04

    POST with the order id as the key

    Authorization from the function's environment, never from the mobile app.

  5. 05

    Write job id back to the row

    A column your support tools can show. Update it when you poll status.

Node.js

// Supabase or Firebase function: receipt for a new order
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': order.id,
  },
  body: JSON.stringify({
    printer_code: Number(process.env.PRINTER_CODE),
    content_type: 'raw',
    content: Buffer.from(receipt).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

Do not call the API from the client SDK

Supabase and Firebase client keys are not a place to hide a print API key. The printer call belongs in a function or a webhook handler.

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

Is there a Supabase integration?

No extension. A database webhook to a function is enough. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.

Firebase Auth users printing their own receipts?

The function checks the user, then uses the server API key. The user's ID token is not a PrintBase key.

How do I isolate tenants?

Store printer_code per tenant. For stronger isolation, use one PrintBase organization per tenant via the Enterprise API (POST /v1/enterprise/orgs and a per-org API key). That API is for Enterprise accounts.

The function timed out.

The print POST is a short HTTPS call. Do not sleep until the printer finishes inside the function if the platform has a short limit. Poll later.

Related guides

  • How to auto-print kitchen tickets from your ordering site

    When your own ordering site takes an order, print an ESC/POS kitchen ticket through the API. The browser must not hold the API key.

  • Print receipts from Express

    An Express route can post an ESC/POS receipt when an order is created. The API key stays in the Express process, not in the static frontend.

  • 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.

  • How to auto-print WooCommerce order receipts

    Print a WooCommerce order receipt from the order-status hook on your server. There is no PrintBase WooCommerce plugin; use the REST API.

Free plan: 100 jobs a month on one computer, no card.

Create a free accountRead the API docs
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds