Skip to content

Latest commit

 

History

History
129 lines (98 loc) · 5 KB

File metadata and controls

129 lines (98 loc) · 5 KB

Create a print job

Queue a ticket on an Expedy cloud thermal receipt printer. This is the most-used endpoint of the API.

POST https://www.expedy.fr/api/v2/printers/{printer_uid}/print

Authentication

Requires an Authorization header — see Authentication.

Path parameters

Name Type Required Description
printer_uid string yes Unique ID of the target printer. Obtain it from GET /printers/all or the Expedy console.

Request body

Content-Type: application/json

Field Type Required Description
printer_msg string yes The ticket content. Plain UTF-8 text mixed with XML-like tags that drive layout, actions and printer parameters. See how to build a ticket.
origin string no Free-form identifier echoed in the Expedy console — useful to trace which system / feature / order emitted the job (e.g. "pos/checkout", "kitchen/prep-slip").
printer_han string no Script used to compose the receipt: cn Chinese, kr Korean, jp Japanese (1 accepted as a synonym of cn). Omit for Latin scripts. Required for Chinese/Japanese/Korean text — without it every such character prints as ?. See Asian characters.

Building the printer_msg payload

printer_msg carries everything: text, line breaks, images, QR codes, cut, cash-drawer pulse, and even one-shot printer configuration (Wi-Fi, NTP, APN, keep-alive).

Full tag reference:

Chinese, Japanese and Korean text

CJK characters need the printer_han field or they print as ? — see Asian characters for the full explanation and examples.

await client.printers.createPrintJob(printerUid, {
  printer_msg: "<C><BOLD>주문 #1234</BOLD></C><BR><CUT/>",
  printer_han: "kr",
});

Response — 200 OK

A 200 confirms the job was accepted and queued — not that it printed. See delivery and idempotency.

Field Type Description
request_uid string Unique identifier for the queued print job.
request_timestamp string Unix timestamp (seconds) when the platform accepted the job. Returned by the API but not part of the documented response contract — treat it as optional.
{
  "request_uid": "2XVXPN95E7RHYFJZCGMK8DSB634",
  "request_timestamp": "1776680582"
}

Examples

curl

curl -X POST "https://www.expedy.fr/api/v2/printers/XG9DMFPKB2C/print" \
  -H "Authorization: $EXPEDY_API_SID:$EXPEDY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "printer_msg": "<C><BOLD>Order #4521</BOLD></C><BR>Coffee x1<BR>Croissant x2<BR><CUT/>",
    "origin": "pos/checkout"
  }'

Node.js — SDK

import { ExpedyClient } from "expedy-sdk-node";

const client = new ExpedyClient({
  apiSid: process.env.EXPEDY_API_SID!,
  apiToken: process.env.EXPEDY_API_TOKEN!,
});

const { request_uid, request_timestamp } = await client.printers.createPrintJob(
  "XG9DMFPKB2C",
  {
    printer_msg:
      "<C><BOLD>Order #4521</BOLD></C><BR>Coffee x1<BR>Croissant x2<BR><CUT/>",
    origin: "pos/checkout",
  },
);

Node.js — raw fetch

const response = await fetch(
  `https://www.expedy.fr/api/v2/printers/${printerUid}/print`,
  {
    method: "POST",
    headers: {
      Authorization: `${process.env.EXPEDY_API_SID}:${process.env.EXPEDY_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ printer_msg: "<C>Hello</C><BR><CUT/>" }),
  },
);

See also