Wocart
Wocart API

Orders

Server

List orders

GET
https://api.wocart.store
/api/orders
X-API-Key (header)

List orders › query Parameters

status
​string · enum
Enum values:
new
confirmed
unreachable
preparing
ready
cancelled
stage
​string

Where the order stands overall — its processing, then its shipment's delivery: one stage, or several separated by commas (new,unreachable)

Where the order stands overall — its processing, then its shipment's delivery: one stage, or several separated by commas (new,unreachable)

attention
​string · enum

true: only orders whose delivery needs the merchant (an unknown handoff, a parcel the carrier cancelled or flagged); false: only the others

true: only orders whose delivery needs the merchant (an unknown handoff, a parcel the carrier cancelled or flagged); false: only the others

Enum values:
true
false
kind
​string · enum

Only orders handed to a carrier, or to the store's driver

Only orders handed to a carrier, or to the store's driver

Enum values:
carrier
driver
archived
​string · enum

Archived orders: left out (default), the only ones listed, or listed with the rest

Archived orders: left out (default), the only ones listed, or listed with the rest

Enum values:
exclude
only
include
Default: exclude
orderType
​string · enum
Enum values:
online
offline
wilayaId
​integer | null
search
​string

Order number, customer name, phone, or the parcel's tracking number

Order number, customer name, phone, or the parcel's tracking number

limit
​integer · max: 100
Default: 50
offset
​integer | null · min: 0
Default: 0
cursor
​string · minLength: 1 · maxLength: 300

Keyset pagination cursor (takes precedence over offset). Pass the (createdAt, id) cursor of the last row of the current page to fetch the next page; deep pages stay index-served unlike offset.

Keyset pagination cursor (takes precedence over offset). Pass the (createdAt, id) cursor of the last row of the current page to fetch the next page; deep pages stay index-served unlike offset.

List orders › Responses

200

Orders, newest first (archived ones left out unless archived says otherwise), with their delivery at a glance: the shipment's kind, carrier or driver and tracking number, the stage and whether it needs the merchant. nextCursor fetches the next page (null on the last one).

success
​boolean · required
​OrderListItem[] · required
count
​integer · required

Number of items returned

nextCursor
​string | null · required

Pass as cursor for the next page; null on the last page


Create order

POST
https://api.wocart.store
/api/orders
X-API-Key (header)

Creates a new order.

Auto-customer creation: If customerId is not found in the customers table (e.g. walk-in / manual entry), the customer is automatically created using customerName, phone, wilayaId, and address. Pass a client-generated UUID (e.g. crypto.randomUUID()) as customerId in this case.

Inventory: Products with trackInventory enabled will have their stock decremented automatically.

Delivery fee: decided as the storefront checkout decides it (POST /orders/delivery-quote shows it): every product's shipping profile, the dearest winning; a commune's own price; free at the store's free-delivery amount; free by an offer for a basket of its product alone, which the order records (deliveryOfferId). An offline order may pass an explicit deliveryFee, which is then kept as typed. Where the store does not deliver, an online order is refused (422 DELIVERY_NOT_AVAILABLE).

Delivery is chosen later, when the ready order is handed to a carrier or a driver (POST /orders/{id}/shipment).

Create order › Request Body

customerId
​string · minLength: 1 · required
customerName
​string · minLength: 1 · required
phone
​string · pattern: ^0[5-7]\d{8}$ · required
wilayaId
​integer · min: 1 · max: 58 · required
communeId
​string · minLength: 1 · required
price
​number · required
​object[] · minItems: 1 · required
city
​string | null
customerEmail
​string | null · email · maxLength: 254
address
​string | null
notes
​string | null
orderType
​string · enum
Enum values:
online
offline
Default: online
deliveryType
​string · enum
Enum values:
home
stop_desk
Default: home
deliveryFee
​number · min: 0

Create order › Responses

Order created successfully

success
​boolean · required
​OrderCreatedData · required
message
​string · required

Quote an order's delivery

POST
https://api.wocart.store
/api/orders/delivery-quote
X-API-Key (header)

What delivery would cost on an order being entered, decided as the storefront checkout decides it — the fee POST /orders charges when no fee is typed — and why it is free when it is: { by: "threshold", threshold } (the store's free-delivery amount) or { by: "offer", offerId, offerName }. { available: false } where the store does not deliver. A read: nothing is written.

Quote an order's delivery › Request Body

​object[] · minItems: 1 · maxItems: 100 · required
subtotal
​number · min: 0 · required
wilayaId
​integer · min: 1 · max: 58 · required
deliveryType
​string · enum · required
Enum values:
home
stop_desk
communeId
​string | null · minLength: 1

Quote an order's delivery › Responses

200

The quote

success
​boolean · required
​required

Get order

GET
https://api.wocart.store
/api/orders/{id}
X-API-Key (header)

Returns full order detail including products and status history.

Get order › path Parameters

id
​string · required

Resource ID

Resource ID

Get order › Responses

200

Order details

success
​boolean · required
​Order · required

Complete order record with products and status history


Update order

PATCH
https://api.wocart.store
/api/orders/{id}
X-API-Key (header)

Partially edits an order's customer and destination fields: customerName, phone, customerEmail, wilayaId, communeId, city, address, deliveryType, notes. All fields optional — omitted fields stay untouched.

This is how a merchant records an address collected over the phone when the checkout hid the address field.

The linked customer record is updated in the same operation with the fields this request changes (name, phone, wilaya/commune, address) — an order and its customer never disagree on contact details. If the corrected phone already belongs to a different customer record, the order is re-pointed to that record instead of overwriting its phone. customerEmail is stored on the order only.

customerEmail / address: an empty (or whitespace) value clears the field; a value is stored trimmed (email also lower-cased), matching POST /orders.

Rejected with 409 ORDER_HAS_SHIPMENT when the order has a shipment and the edit touches what the parcel carries (name, phone, wilaya, commune, city, address, delivery type) — change those through PATCH /shipments/{id}; the email and notes still change. Rejected with 422 for a legacy order that already has a tracking number, or one in a terminal state (returned/cancelled). Rejected with 400 MISSING_ADDRESS when the edit would leave a home delivery without a street address. Wilaya/commune are checked against the reference tables (400 MISSING_WILAYA_COMMUNE).

Update order › path Parameters

id
​string · required

Resource ID

Resource ID

Update order › Request Body

customerName
​string · minLength: 1
phone
​string · pattern: ^0[5-7]\d{8}$
customerEmail
​string | null · email · maxLength: 254
wilayaId
​integer · min: 1 · max: 58
communeId
​string · minLength: 1
city
​string | null
address
​string | null
deliveryType
​string · enum
Enum values:
home
stop_desk
notes
​string | null

Update order › Responses

Order updated — returns the refreshed order detail

success
​boolean · required
​Order · required

Complete order record with products and status history

message
​string · required

Delete order

DELETE
https://api.wocart.store
/api/orders/{id}
X-API-Key (header)

Permanently deletes an order never handed to delivery, in any status: the goods still out of stock go back, the customer's order count and spend are undone, and its lines, history, reviews and logs go with it. 409 ORDER_HAS_SHIPMENT once it has a shipment — its parcel, the driver's cash and the carrier's records rest on it; archive it when its delivery has ended (POST /orders/{id}/archive), or void the shipment first. The database refuses it too.

Delete order › path Parameters

id
​string · required

Resource ID

Resource ID

Delete order › Responses

Order deleted

success
​boolean · required
message
​string · required

What clearing an order away does

GET
https://api.wocart.store
/api/orders/{id}/removal
X-API-Key (header)

Whether the order can be deleted (never handed to delivery) or archived (finished: cancelled, or its shipment delivered, returned or cancelled), and what deleting it would undo — read before asking the merchant to confirm.

What clearing an order away does › path Parameters

id
​string · required

Resource ID

Resource ID

What clearing an order away does › Responses

200

The order's removal options

success
​boolean · required
​OrderRemoval · required

Archive order

POST
https://api.wocart.store
/api/orders/{id}/archive
X-API-Key (header)

Takes a finished order — cancelled, or its shipment delivered, returned or cancelled — out of the working lists and their counts. It still counts in sales and the customer's history, and can be restored. Archiving it again keeps the first date. 409 ORDER_NOT_FINISHED before then.

Archive order › path Parameters

id
​string · required

Resource ID

Resource ID

Archive order › Responses

Archived

success
​boolean · required
​object · required

Restore an archived order

POST
https://api.wocart.store
/api/orders/{id}/unarchive
X-API-Key (header)

Brings an archived order back to the working lists.

Restore an archived order › path Parameters

id
​string · required

Resource ID

Resource ID

Restore an archived order › Responses

200

Restored

success
​boolean · required
​object · required

Update order status

PATCH
https://api.wocart.store
/api/orders/{id}/status
X-API-Key (header)

Moves the order's processing and appends a record to its status history (cod-shared/orders/lifecycle.ts):

  • new → confirmed | unreachable | cancelled
  • confirmed → preparing | ready | unreachable | cancelled
  • unreachable → confirmed | cancelled (the customer did not answer; call again)
  • preparing → ready | cancelled
  • ready → cancelled; a ready order is handed off with POST /orders/{id}/shipment
  • cancelled is final

Any other move returns 400 INVALID_STATUS_TRANSITION with the allowed next statuses.

Side effects: confirmed starts the Meta CAPI confirmed stage (when the store tracks it); cancelled restores inventory for products with trackInventory and rolls back the customer's spend. Delivery and return are the shipment's milestones, with their own effects.

Each effect applies exactly once, even when the same change is sent twice at once. An order with a shipment has no status change (409 ORDER_HAS_SHIPMENT): its delivery is the shipment's, and cancelling it means voiding the shipment first.

Update order status › path Parameters

id
​string · required

Resource ID

Resource ID

Update order status › Request Body

status
​string · enum · required
Enum values:
new
confirmed
unreachable
preparing
ready
cancelled

Update order status › Responses

Status updated

success
​boolean · required
message
​string · required

Record a product line return

PATCH
https://api.wocart.store
/api/orders/{id}/products/{productLineId}/return
X-API-Key (header)

Records how many units on a single order line the customer refused at the door. Used for the Algerian "open the box at delivery" workflow where a customer may accept part of an order and return the rest.

The server computes the line status ("fulfilled" | "partially_returned" | "returned") from returnedQuantity vs. the line quantity, restocks the delta (repeated calls are idempotent), and logs an ORDER_RETURNED stock movement.

Only on a delivered order: the customer opened the parcel at the door and kept part of it. Before delivery nothing has been refused (422 ORDER_NOT_DELIVERED) — a parcel refused whole comes back as a return, and its stock with it.

Refused (422) once the order is cancelled or its parcel came back — every remaining unit is already back in stock. Both are checked in the same write, so neither can happen in between.

Record a product line return › path Parameters

id
​string · required

Resource ID

Resource ID

productLineId
​string · required

Order product line ID

Order product line ID

Record a product line return › Request Body

returnedQuantity
​integer · min: 0 · required

Record a product line return › Responses

Return recorded

success
​boolean · required
​ReturnProductData · required
message
​string · required