Register sales
POST /api/v1/pos/register/sales makes one register sale in one request: the
order, its lines, a coupon, loyalty points, a gift card, the payments and the cash
in the drawer. They are written in one database transaction, or nothing is
written. The call is safe to retry. It is what the register screen of the back
office uses to charge a ticket. It needs the Point of sale module and a person's
token (API overview).
Contract, with limits
This page describes a contract that the register screen depends on, so it is kept stable on purpose. It has automated tests but has not yet been in daily use by shops; treat it as new.
All money is whole cents: 1235 is 12.35. A value that is not a whole JSON
number (12.5 or "1235") is refused. The server works out the total and its
total is the one that counts: the client sends the total it showed, and the server answers
409 when it differs.
A register sale is always paid in full when it is made. For an unpaid order, an
order on account, or an order for later, use POST /api/v1/pos/orders as the
back-office form does.
Who may call it
A staff member needs both pos.orders#create and pos.register#use if a profile
limits them. A viewer is refused. A line discount needs pos.register#discount.
A price other than the catalogue price needs pos.register#override_price. These
two are sensitive: a person without a profile does not have them. See
Roles and permissions.
Request
Headers: Authorization: Bearer <token> and Content-Type: application/json.
Optional: Accept-Language: nl or en for the texts of error messages.
{
"idempotency_key": "ticket-2026-11-14-0001",
"register_shift_id": 12,
"expected_total_cents": 1235,
"customer_id": 41,
"notes": "Birthday",
"lines": [
{"product_id": 7, "quantity": 1},
{"product_id": 9, "option_id": 3, "quantity": 2, "unit_price_cents": 1000,
"discount_cents": 100, "surcharge_cents": 0, "note": "gift wrap"}
],
"coupon_code": "SPRING10",
"loyalty_points": 100,
"gift_card": {"code": "EXAMPLE-CODE", "amount_cents": 500},
"payments": [
{"payment_method_id": 3, "amount_cents": 735, "cash_received_cents": 1000}
],
"fulfilment": {"method": "pickup", "date": "2026-11-20"}
}| Field | Type | Required | Meaning |
|---|---|---|---|
idempotency_key | text, 8 to 100 characters of A-Z a-z 0-9 - _ : . | yes | Made by the client once per ticket. See Retries. |
expected_total_cents | whole number, 0 or more | yes | The total the screen showed. |
register_shift_id | whole number | for cash | The open shift of the register. It must be open and on one of the shop's own drawers. Optional for a sale without cash; when given, the order and its payments carry it. |
customer_id | whole number | no | One of the shop's customers. Without it the sale goes to a "Walk-in customer". |
notes | text, up to 2000 | no | Order notes. |
lines | list of 1 to 200 | yes | The ticket. |
lines[].product_id | whole number | yes | A product of the shop. |
lines[].option_id | whole number | no | An active option of that product, such as a size. Without unit_price_cents the line is priced at the option's price. |
lines[].quantity | whole number, 1 to 9999 | yes | |
lines[].unit_price_cents | whole number, 0 or more | no | Price per unit. Left out, the catalogue price (or the option's price) is used. A different price needs pos.register#override_price. |
lines[].discount_cents | whole number, 0 or more | no | Amount taken off the line, in cents, not a percentage. Needs pos.register#discount. Never more than the line. |
lines[].surcharge_cents | whole number, 0 or more | no | Amount added to the line. |
lines[].note | text, up to 500 | no | Line note. |
coupon_code | text | no | A coupon code of the shop. |
loyalty_points | whole number, 0 or more | no | Points of the order's customer to spend. |
gift_card | object with code and amount_cents | no | A gift card of the shop and how much of it pays. Both fields are required. |
payments | list of up to 10 | yes, unless the total is 0 | The money taken, other than the gift card. |
payments[].payment_method_id | whole number | yes | An active payment method of the shop that is accepted at the register. On-account methods, online methods and the gift card method are refused (use gift_card). |
payments[].amount_cents | whole number above 0 | yes | What this payment pays of the order. |
payments[].cash_received_cents | whole number | cash only | What the customer handed over, at least amount_cents. Left out for cash: exactly amount_cents. Not allowed for other methods. |
fulfilment | object | no | Collection or delivery details, as order[fulfilment] of POST /api/v1/pos/orders. |
Fields that are not in the table are refused with unknown_field, so a typo
cannot silently drop a discount.
The sum rule
The server applies the lines, the coupon and the loyalty points, then checks the
total against expected_total_cents, then applies the gift card and the payments.
gift_card.amount_cents plus the sum of payments[].amount_cents must equal the
total. More is refused (payments_exceed_total): only cash can be handed over
above the amount, through cash_received_cents, and the change is the
difference. Less is refused (payments_short).
Success: 201 Created
{
"data": {
"order": {
"id": 8812, "number": 3925, "formatted_number": "003925",
"status_id": 5, "status": "Done",
"customer_id": 41, "customer_name": "Example customer",
"register_shift_id": 12, "order_date": "2026-11-14T17:02:11.000-04:00",
"total_cents": 1235, "paid_cents": 1235,
"adjustments": [{"kind": "coupon", "label": "SPRING10", "amount_cents": 200}],
"lines": [
{"id": 20551, "product_id": 7, "name": "Example product", "quantity": 1,
"unit_price_cents": 1235, "discount_cents": 0, "surcharge_cents": 0,
"tax_rate": "0.0", "tax_cents": 0, "total_cents": 1235, "note": null}
]
},
"payments": [
{"id": 9901, "payment_method_id": 3, "payment_method_name": "Cash",
"amount_cents": 1235, "kind": "cash", "cash_received_cents": 2000,
"change_cents": 765, "register_shift_id": 12}
],
"change_due_cents": 765
},
"meta": {"replayed": false}
}change_due_cents is the cash to hand back, added up over the cash payments.
kind is cash (it uses the cash drawer) or other. The gift card payment is
in payments too. The sold units leave the stock inside the sale, so with a
stock policy that enforces stock, two sales of the last unit end in one sale and
one out_of_stock.
Retries
Make the key when the cashier taps Charge, keep it with the ticket, and resend the same key with the same body after a timeout or a network error. Do not send a new key for the same ticket unless the cashier changed it.
| Situation | Answer |
|---|---|
| First request | 201, meta.replayed: false. |
| Same key and same body after the first succeeded | 200, the first order and payments again, meta.replayed: true. Nothing is written. |
| Same key, different body | 409 with code idempotency_key_reused. |
| Same key after a request that was refused | Treated as new. A refused sale leaves nothing behind. |
"Same body" means the same JSON content; 1235 and "1235" differ. Resend only
as part of the ticket's own retry, not days later: a key does not outlive its
order, so a resend after the order was deleted makes a new sale.
Errors
An error is JSON: {"error": "<text>", "errors": ["<text>"], "code": "<code>"},
plus extra fields. The text is English and for logs; build the message for the
cashier from code.
409, nothing written
code | When | Extra fields |
|---|---|---|
total_mismatch | The server's total differs from expected_total_cents. | server_total_cents, expected_total_cents |
idempotency_key_reused | Same key, different body. |
On total_mismatch, show the server's total and let the cashier confirm, then
send again with the same key and expected_total_cents set to the server's total.
422, nothing written
code | Meaning |
|---|---|
unknown_field | A field that is not in the contract (field). |
invalid_<field> | A field is missing, not a whole number, out of range or too long, for example invalid_lines, invalid_payments, invalid_quantity (field). |
discount_exceeds_line | A line discount is more than the line (field, line_cents). |
unknown_product, unknown_option, unknown_customer, unknown_payment_method | The id is not one of the shop's. |
unknown_shift | register_shift_id is closed, being closed, not on the shop's own drawers, or unknown. |
shift_required | A cash payment without register_shift_id. |
payment_method_not_allowed | An on-account, inactive, online or gift card method. |
method_not_accepted_at_register | The method is not accepted at the register. |
payments_short, payments_exceed_total | The payments do not match the total (total_cents, payments_cents, and short_cents). |
cash_received_too_low, cash_received_not_allowed | cash_received_cents is below the amount, or used on a method that is not cash. |
out_of_stock | A line is not on hand (shortages: product, requested, available). |
coupon_not_usable | Unknown, expired or used-up coupon. |
loyalty_failed | No loyalty account, not enough points, or the programme is off. |
gift_card_unknown, gift_card_unusable, gift_card_insufficient, gift_card_invalid | The gift card cannot pay this amount. |
fulfilment_invalid, time_slot_unavailable | Collection or delivery details do not validate, or the slot is not available. |
no_order_status, no_payment_method | The shop is not set up to sell. |
invalid | A record was refused by its own validation (errors). |
Other
400withinvalid_json: the body is not JSON.401: not signed in.403withcode: "permission_required"andpermission: a discount or a price change without the permission.403withreason: "missing_permission"andpermission: the person lackspos.orders#createorpos.register#use.
If a gift card, coupon or loyalty step fails after the order was started, all of it is rolled back.
What this call does not do
- No unpaid, partial or on-account sale. Use
POST /api/v1/pos/orders. - No online payment through a payment service.
- No refunds. Refunds have their own endpoints.
Parked tickets
A parked ticket is a ticket the cashier puts aside. It is a small record, not an
order: no order number, no stock movement, no mail. The ticket is the client's own
JSON; the server reads only ticket["lines"].size for line_count.
All calls need pos.register#use. A membership role of viewer is refused even
without a profile. Tickets of closed shifts are not listed and cannot be recalled.
| Call | Body or header | Answer |
|---|---|---|
POST /api/v1/pos/register/parked_tickets | {register_shift_id, label?, customer_id?, total_cents, ticket} | 201 with the ticket. |
GET /api/v1/pos/register/parked_tickets | ?register_shift_id= (optional) | 200 with the tickets, newest first. Tickets that another tablet is recalling are hidden. |
POST /api/v1/pos/register/parked_tickets/:id/recall | header X-Register-Device | 200 with the ticket, now claimed by this tablet. 409 with already_claimed when another tablet claimed it in the last two minutes. |
DELETE /api/v1/pos/register/parked_tickets/:id | header X-Register-Device | 200: the ticket is deleted. 409 with claim_lost when another tablet holds it now: the client must empty its cart. |
A recall is two steps: recall claims the ticket and returns it, and the client
sends DELETE once the cart is loaded. If the client never confirms, the claim
runs out after two minutes and the ticket is listed again.
X-Register-Device is a random id of 8 to 64 characters of A-Z a-z 0-9 _ - that
each tablet makes once and keeps. A claim belongs to a tablet, not to a login,
because small shops share one login. Missing or malformed: 422 with
device_required.
A ticket:
{"id": 5, "label": "Example ticket", "customer_id": 41, "customer_name": "Example customer",
"register_shift_id": 12, "total_cents": 1235, "line_count": 2,
"created_at": "2026-11-14T17:02:11.000Z", "claimed_at": null,
"claimed_by_this_device": false, "created_by_name": "Example cashier",
"ticket": {"lines": []}}Errors on parking are 422 with unknown_shift, unknown_customer,
invalid_total_cents, invalid_label (text up to 100), invalid_ticket (not an
object, or over 100 KB), unknown_field or too_many_parked (50 per shift).
Closing a cash drawer with parked tickets on its shift is refused with 422 and
code: "parked_tickets" unless the body has "discard_parked": true; then every
parked ticket of the shift is deleted with the close. That needs
pos.cash_drawers#close.