POS through the API
What you can do
Section titled “What you can do”- Read registers, shifts, sales, sale lines, payments and returns.
- Open and close a shift, sell, put a cart on hold, void a sale and take a return.
- Prepare the fiscal receipt of a sale and the refund receipt.
This is the admin API (/api/v1), with the company secret key. The POS module must be on. The key stays on the server.
Key scopes
Section titled “Key scopes”| What you do | Scope |
|---|---|
| read | pos:read |
| sell, open and close shifts, void, return | pos:write |
| issue the fiscal receipt | fiscal:write |
| issue the refund receipt | fiscal:write and pos:write |
A key with pos:write has no discount limit. The limit in settings applies to people without manage rights on POS. If your app lets a seller give discounts, you enforce the limit.
The register
Section titled “The register”A register (pos_registers) says which warehouse goods leave from and which cash book cash goes into. Both are optional: when empty, a sale does not touch them.
POST /api/v1/pos_registers
{ "name": "Event register", "warehouse_id": "<warehouse uuid>", "product_ids": ["<product uuid>", "<product uuid>"]}product_ids limits what the register sells. An empty list means all POS products. A product with pos_hidden: true is not sold on any register.
Register prices
Section titled “Register prices”A register can sell at other prices, for example at an event:
{ "price_adjust_pct": 10, "price_overrides": { "<product uuid>": 25 } }price_adjust_pct raises or lowers all prices on the register (from -90 to 500). price_overrides are special prices including VAT, by product id, and take priority. On update, what you do not send stays; {} removes the special prices. Product prices and the online shop do not change.
Stock shared with the online shop
Section titled “Stock shared with the online shop”- Same stock:
warehouse_idis a warehouse the online shop also sells from. The counter cannot sell pieces that are in carts or in online orders not yet shipped (response409, if negative stock is not allowed), and after each sale the shop receivesshop.changed. - Separate stock:
warehouse_idis a warehouse that does not sell online, which you moved goods into. The shop does not see it.
The shift
Section titled “The shift”POST /api/v1/commands/pos.open_session
{ "register_id": "<register uuid>", "opening_cash": 200 }A register has a single open shift. To close it:
POST /api/v1/pos_sessions/{id}/close
{ "counted_cash": 1512.5, "note": "all good" }The response has the number of sales, cash and card takings, returns, the expected cash and the difference. The full report, with VAT by rate: POST /api/v1/pos_sessions/{id}/report.
The sale
Section titled “The sale”POST /api/v1/commands/pos.create_sale
{ "register_id": "<register uuid>", "lines": [ { "product_id": "<product uuid>", "qty": 2 }, { "product_id": "<product uuid>", "qty": 1, "discount_pct": 10 } ], "payments": [ { "method": "card", "amount": 20 }, { "method": "cash", "tendered": 50 } ], "idempotency_key": "cart-7f3a2c91"}- Prices come from the catalog, VAT included. You do not send them.
payments:cashorcard. One payment may come withoutamountand takes what is left. For cash,tenderedis what the customer handed over, and the response has thechange.idempotency_key: a new key for each cart, the same one on retry. If you get no response, send the same request again: the sale is not made twice. The same key with a different total is refused.expected_total(optional): the total you showed the customer. If prices changed, the sale is not made.- Stock: if there is not enough and negative stock is not allowed, the response is
409. If it is allowed, the sale goes through with a text inwarnings.
Carts on hold
Section titled “Carts on hold”pos.park_cart takes register_id, lines and optionally discount_pct and note. When taking payment, send parked_id to pos.create_sale: a cart can be paid only once. pos.discard_cart deletes it.
Voids and returns
Section titled “Voids and returns”Voiding only works while the shift of the sale is still open:
POST /api/v1/pos_sales/{id}/void with { "reason": "wrong product scanned" }
A return can be partial and is made from the open shift of the register that pays the money out:
POST /api/v1/pos_sales/{id}/return
{ "register_id": "<register uuid>", "lines": [{ "line_id": "<row uuid from pos_sale_lines>", "qty": 1, "restock": true }], "method": "cash", "reason": "does not fit", "idempotency_key": "return-91bd02aa"}With method: "card", at most what was paid by card goes back to the card, and the rest in cash. restock: false gives the money back without putting the goods back into stock. A sale with a return can no longer be voided.
The fiscal receipt
Section titled “The fiscal receipt”The fiscal printer is on the computer at the counter, so the ERP prepares the commands and your app hands them to the driver.
POST /api/v1/commands/fiscal.preparewithsource: "pos_sale",source_id(the sale) andregister_id(the fiscal printer).- Send
commandsorcontentto the driver. - Report the outcome with
POST /api/v1/fiscal_receipts/{id}/result:sent,printedorfailed.
A sale has a single receipt, even with a split payment. A rejected receipt is retried with the same command. For a return, pos.return_receipt with return_id gives the refund receipt, and its outcome goes to fiscal_operations/{id}/result.
Settings
Section titled “Settings”GET and PUT /api/v1/settings/pos.settings: maxDiscountPct, the discount limit. max_discount_pct also works when writing.
/api/v1resources:pos_registers,pos_sessions,pos_sales,pos_sale_lines,pos_payments,pos_returns,pos_return_lines.- Webhooks: for example
pos_sales.createdandpos_returns.created.