Orders API

Manage orders programmatically.

Overview

The Orders API lets you manage orders programmatically. All admin endpoints are under /api/admin/orders.

Endpoints

MethodPathDescription
GET/api/admin/ordersList orders with pagination and filters
POST/api/admin/ordersCreate 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 email
  • status β€” filter by order status
  • excludeStatus β€” exclude specific statuses
  • source β€” filter by order source
  • page and limit β€” 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 | CANCELLED
  • PAID β†’ IN_PRODUCTION | PROCESSING | REFUNDED
  • IN_PRODUCTION β†’ PROCESSING
  • PROCESSING β†’ SHIPPED
  • SHIPPED β†’ DELIVERED

Invalid transitions return 422 with code: "invalid_transition" and the allowed next states in the response body.

Webhooks emitted

  • order.created β€” fired on POST
  • order.updated β€” fired on any PATCH
  • order.paid β€” when payment status crosses to PAID
  • order.shipped β€” when status moves to SHIPPED (includes tracking number)
  • order.cancelled, order.refunded

Was this article helpful?

Orders API β€” Manage Orders Programmatically | K99