Selling cash on delivery
Stock and inventory
Read stock the way the Inventory page shows it, change it with a reason, follow every movement, book deliveries in and run stock counts.
The stock picture
GET /v1/inventory lists one inventory level per variant, the same numbers as the dashboard's Inventory page:
| Field | Means |
|---|---|
available | What can still be ordered. Goes negative when pre-orders or back-orders took more than the shelf holds. |
committed | Units taken by orders that haven't gone to a courier yet. |
on_hand | available + committed: what should physically be there. |
incoming, incoming_due_at | A delivery on its way, and when it is expected. |
at_courier, on_shelf | Units kept at the courier's warehouse, and the rest. |
low_stock | At or under the store's alert level (GET /v1/inventory_settings). |
sold_30d, days_of_cover | Units sold in the last 30 days, and how long the stock lasts at that pace. |
Filter with filter (low, out, reorder, incoming, courier, untracked), search by title, SKU or barcode with search, and sort by name, runway (soonest to run out first) or newest. One variant: GET /v1/inventory/{variant_id}.
Changing stock
Every change goes through the stock history, with a reason. POST /v1/inventory/adjustments takes up to 100 lines at once, all or nothing:
curl -X POST https://api.ordexs.com/v1/inventory/adjustments \
-H "Authorization: Bearer $ORDEXS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"reason": "restock",
"note": "Supplier delivery #118",
"lines": [
{ "variant_id": "var_2f0e1d3c4b5a49688776655443322110", "delta": 24 },
{ "variant_id": "var_3a0e1d3c4b5a49688776655443322111", "set": 6 }
]
}'deltaadds or removes units;setgives the new count. One per line.reasonisrestock(new units arrived),correction(the count was wrong) ormanual_adjust(anything else).- Always send an
Idempotency-Key: a retrieddeltamust not add the units twice.
Orders move stock on their own (a sale, a cancellation, a return), and each of those moves is in the history too. Every change fires an inventory.updated webhook.
The stock history
GET /v1/inventory_movements is the ledger: one entry per change, with delta, balance_after, reason, the order that caused it, and the actor (a person, an API key with its name, or Ordexs itself). Filter by variant_id or reason. With created_since the list runs oldest first, so a system can keep its place and pick up only new movements.
The merchant sees the same history in the dashboard, with your API key's name on your changes.
Back-orders, pre-orders and deliveries
These are the switches on the Inventory page:
- Back-orders (
PATCH /v1/variants/{id}withallow_backorder): the variant sells past zero with no limit, and the merchant owes the units. - Incoming delivery (
incoming: { quantity, due_in_days }on the same PATCH): units on their way. Pre-orders (allow_preorderonPATCH /v1/products/{id}) let customers order against it, up to what is coming. An order can also be marked as a pre-order on its own: see Orders. - Receiving it:
POST /v1/variants/{id}/receive_incomingbooks the delivery into stock when it lands. - Stock at the courier (
at_courier): units the merchant keeps in the courier's warehouse, for couriers that ship from their own stock.
Turning back-orders or pre-orders off is refused while units are still owed: receive the stock first.
Stock counts
A count sheet freezes what Ordexs expects for each variant, so a team can count while sales go on:
POST /v1/stock_countsopens one (optionally limited withfilterandsearch).POST /v1/stock_counts/{id}/linesrecords what was counted, up to 500 lines per call.POST /v1/stock_counts/{id}/applymakes each counted line the variant's stock, as acorrection. Lines nobody counted are left alone. Or…/discardcloses it without changing anything.
Each line shows expected (at opening), counted, current (now) and the variance that applying will make.
