Orders API
Manage orders programmatically.
Overview
The Orders API lets you manage orders programmatically. All admin endpoints are under /api/admin/orders.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/admin/orders | List orders with pagination and filters |
POST | /api/admin/orders | Create a manual order |
GET | /api/admin/orders/[id] | Get order details with line items |
PATCH | /api/admin/orders/[id] | Update order status, assign sales rep |
DELETE | /api/admin/orders/[id] | Delete an order (Owner only) |
Query parameters
searchβ search by order number, customer name, or emailstatusβ filter by order statusexcludeStatusβ exclude specific statusessourceβ filter by order sourcepageandlimitβ pagination
Creating orders via API
When creating an order via API, you can specify:
- Customer (by ID or create inline)
- Line items with product variants and quantities
- Order source (IN_PERSON, PRIVATE_COMMISSION, etc.)
- Sales rep assignment
- Custom order date (for backdating)
- Notes and tags
Example: create an in-person order
curl https://yourdomain.com/api/admin/orders \
-X POST \
-H "Authorization: Bearer kat_live_..." \
-H "Idempotency-Key: 8b8a2b9e-4a5c-4f9d-9e2a-1f3a8b8a2b9e" \
-H "Content-Type: application/json" \
-d '{
"source": "IN_PERSON",
"customer": { "email": "alice@example.com", "firstName": "Alice", "lastName": "Smith" },
"salesRepId": "emp_01HX...",
"lineItems": [
{ "variantId": "var_01HX...", "quantity": 1, "price": 4800.00 }
],
"currency": "USD",
"tax": 384.00,
"subtotal": 4800.00,
"total": 5184.00,
"paymentStatus": "PAID",
"paymentMethod": "CARD_TERMINAL",
"note": "Walk-in, sized to 6.5"
}'Status transitions
Use PATCH /api/admin/orders/[id] with { "status": "..." }. Valid transitions:
PENDINGβPAID|CANCELLEDPAIDβIN_PRODUCTION|PROCESSING|REFUNDEDIN_PRODUCTIONβPROCESSINGPROCESSINGβSHIPPEDSHIPPEDβDELIVERED
Invalid transitions return 422 with code: "invalid_transition" and the allowed next states in the response body.
Webhooks emitted
order.createdβ fired on POSTorder.updatedβ fired on any PATCHorder.paidβ when payment status crosses to PAIDorder.shippedβ when status moves to SHIPPED (includes tracking number)order.cancelled,order.refunded
