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"}
}
FieldTypeRequiredMeaning
idempotency_keytext, 8 to 100 characters of A-Z a-z 0-9 - _ : .yesMade by the client once per ticket. See Retries.
expected_total_centswhole number, 0 or moreyesThe total the screen showed.
register_shift_idwhole numberfor cashThe 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_idwhole numbernoOne of the shop's customers. Without it the sale goes to a "Walk-in customer".
notestext, up to 2000noOrder notes.
lineslist of 1 to 200yesThe ticket.
lines[].product_idwhole numberyesA product of the shop.
lines[].option_idwhole numbernoAn active option of that product, such as a size. Without unit_price_cents the line is priced at the option's price.
lines[].quantitywhole number, 1 to 9999yes
lines[].unit_price_centswhole number, 0 or morenoPrice per unit. Left out, the catalogue price (or the option's price) is used. A different price needs pos.register#override_price.
lines[].discount_centswhole number, 0 or morenoAmount taken off the line, in cents, not a percentage. Needs pos.register#discount. Never more than the line.
lines[].surcharge_centswhole number, 0 or morenoAmount added to the line.
lines[].notetext, up to 500noLine note.
coupon_codetextnoA coupon code of the shop.
loyalty_pointswhole number, 0 or morenoPoints of the order's customer to spend.
gift_cardobject with code and amount_centsnoA gift card of the shop and how much of it pays. Both fields are required.
paymentslist of up to 10yes, unless the total is 0The money taken, other than the gift card.
payments[].payment_method_idwhole numberyesAn 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_centswhole number above 0yesWhat this payment pays of the order.
payments[].cash_received_centswhole numbercash onlyWhat the customer handed over, at least amount_cents. Left out for cash: exactly amount_cents. Not allowed for other methods.
fulfilmentobjectnoCollection 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.

SituationAnswer
First request201, meta.replayed: false.
Same key and same body after the first succeeded200, the first order and payments again, meta.replayed: true. Nothing is written.
Same key, different body409 with code idempotency_key_reused.
Same key after a request that was refusedTreated 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

codeWhenExtra fields
total_mismatchThe server's total differs from expected_total_cents.server_total_cents, expected_total_cents
idempotency_key_reusedSame 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

codeMeaning
unknown_fieldA 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_lineA line discount is more than the line (field, line_cents).
unknown_product, unknown_option, unknown_customer, unknown_payment_methodThe id is not one of the shop's.
unknown_shiftregister_shift_id is closed, being closed, not on the shop's own drawers, or unknown.
shift_requiredA cash payment without register_shift_id.
payment_method_not_allowedAn on-account, inactive, online or gift card method.
method_not_accepted_at_registerThe method is not accepted at the register.
payments_short, payments_exceed_totalThe payments do not match the total (total_cents, payments_cents, and short_cents).
cash_received_too_low, cash_received_not_allowedcash_received_cents is below the amount, or used on a method that is not cash.
out_of_stockA line is not on hand (shortages: product, requested, available).
coupon_not_usableUnknown, expired or used-up coupon.
loyalty_failedNo loyalty account, not enough points, or the programme is off.
gift_card_unknown, gift_card_unusable, gift_card_insufficient, gift_card_invalidThe gift card cannot pay this amount.
fulfilment_invalid, time_slot_unavailableCollection or delivery details do not validate, or the slot is not available.
no_order_status, no_payment_methodThe shop is not set up to sell.
invalidA record was refused by its own validation (errors).

Other

  • 400 with invalid_json: the body is not JSON.
  • 401: not signed in.
  • 403 with code: "permission_required" and permission: a discount or a price change without the permission.
  • 403 with reason: "missing_permission" and permission: the person lacks pos.orders#create or pos.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.

CallBody or headerAnswer
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/recallheader X-Register-Device200 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/:idheader X-Register-Device200: 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.