Issue a sale
POST /v1/sales needs the sales:write scope. Send an Idempotency-Key so a retried
request cannot file a second invoice.
The tax on each line comes from the item. See Core concepts.
Discounts
A line discount is taken off the line before tax is worked out. Forquantity: 2, unitPrice: 20880 and
discountRate: 10, the discount is 4,176.00, the line total is 37,584.00, and the VAT is split out of that figure.
Send either field; the other is worked out and both come back on each line of the sale. The receipt shows the
discount under the line, with Total before discount and Total discount awarded above the sub total.
Outcomes
A
422 carries one of these codes, and each includes the sale so you can see what was stored:
A
409 with conflict means the traderInvoiceNumber already exists under a different idempotency key. A 409
with insufficient_stock means a stock-tracked item has too little stock: add stock and retry. See
Stock.
A request that is malformed is a 400 before anything is stored. It names the first field that is wrong, for
example lines[0].quantity must be greater than 0.
Retry a sale
A sale that failed, or never reached KRA, still exists. Re-submit it withPOST /v1/sales/{id}/retry, which needs
sales:write and takes no body. It returns 200 with the sale, or a 422 kra_rejected if KRA refuses it again.
The same call works on credit notes.
Read a sale
GET /v1/sales/{id} returns the sale, with its lines, totals, receipt and the state of its
callback. It needs sales:read.
GET /v1/sales lists sales and credit notes, newest first, a page at a time. Filter by date with startDate and
endDate. See Pagination.
Download the receipt
GET /v1/sales/{id}/receipt returns the KRA receipt as a PDF, with the verification QR code. It needs
sales:read.
copy=true gives a customer copy marked COPY, for reprints. A receipt exists only once KRA has accepted the
sale. Before that, the call is a 404 with the message No receipt yet: KRA has not accepted this sale.
The same details are in the receipt object on the sale: cuInvoiceNo, signature, internalData and a
verificationUrl that opens the receipt on KRA’s side. For how the receipt is laid out, see
Technology Architecture.
Read next
- Credit notes: reverse an accepted sale
- Result callbacks: be told the outcome instead of polling
- Errors & Troubleshooting: every error code