Edge Server API routes
Base URL: http://<edge-server-ip>:3005 (see server/src/config/edgeServer.ts).
Thin Clients must only call the Edge Server over LAN. They must not call WooCommerce/WordPress directly, and they must not access printers directly.
Products
GET /api/products
Returns the product list for the POS UI (Woo export-shaped schema).
- 200:
PosProductResponse[] - 500:
{ error, details }
Defined in server/src/index.ts and backed by buildPosProductResponses() (server/src/services/productApi.ts).
PATCH /api/products/:id
Staff edit a product locally and enqueue push to Woo (unless Local_Only).
Body: arbitrary fields; special-case local_only / Local_Only to set the local-only flag.
- 200:
{ success: true, id, product } - 404:
{ error: 'Product not found' } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
PATCH /api/products/:id/local-only
Toggle local-only on a product.
Body: { local_only?: boolean, Local_Only?: boolean }
- 200:
{ success: true, id, local_only } - 404:
{ error: 'Product not found' } - 500:
{ error, details }
Defined in server/src/index.ts.
Orders
POST /api/orders
Create a Till order locally (ADR 0006); emits realtime order_upserted. Does not queue Woo order sync.
Body: { id?, total?, payment_method?, status?, line_items? }
- 200:
{ success: true, id } - 500:
{ error, details }
Defined in server/src/index.ts.
GET /api/orders/kitchen
Active kitchen board orders from SQLite (Till rows with kitchen_dismissed = 0; Web rows with non-terminal Woo status).
- 200:
{ orders: OrderUpsertedPayload[] } - 500:
{ error, details }
Defined in server/src/routes/orderLanRoutes.ts.
PATCH /api/orders/:id
Till-only kitchen dismiss. Body: { kitchen_dismissed: true }.
- 200:
{ success: true, order }+order_upsertedbroadcast - 400/403/404: invalid body, Web order, or unknown id
- 500:
{ error, details }
Defined in server/src/routes/orderLanRoutes.ts.
GET /api/orders/:id
Read a single order from SQLite (Till or Web).
- 200: order detail including
line_items,delivery_fee,customer_note,receipt_printed,kitchen_dismissed(Till only) - 404:
{ error: 'Order not found' } - 500:
{ error, details }
Defined in server/src/routes/orderLanRoutes.ts.
GET /api/orders/eod
End-of-day report for a local calendar date.
Query: date=YYYY-MM-DD (optional; defaults to today)
- 200: EOD report payload
- 400: invalid date
- 500:
{ error, details }
Defined in server/src/routes/eodRoutes.ts.
Customers (LAN API)
GET /api/customers
List customers (local fields only), includes repeat_orders.
- 200:
CustomerLanResponse[] - 500:
{ error, details }
Defined in server/src/routes/customerRoutes.ts.
POST /api/customers
Create a Customer locally at the till; enqueues async Customer push to Woo.
Body: { first_name?, last_name?, email?, phone?, billing_json?, shipping_json? }
- 201:
CustomerLanResponse - 500:
{ error, details }
Defined in server/src/routes/customerRoutes.ts.
GET /api/customers/:id
Get one customer by id.
- 200:
CustomerLanResponse - 404:
{ error: 'Customer not found' } - 500:
{ error, details }
Defined in server/src/routes/customerRoutes.ts.
PATCH /api/customers/:id
Staff edit a customer locally and enqueue push to Woo.
Body: { first_name?, last_name?, email?, phone?, billing_json?, shipping_json? }
- 200:
{ success: true, id, customer } - 404:
{ error: 'Customer not found' } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
Printing
POST /api/print/label
Request a label print job by catalog product id.
Body: { productId: string, quantity?: number }
- 202:
{ jobId } - 400:
{ error: 'productId is required' } - 404:
{ error: 'Product not found' } - 500:
{ error, details }
Defined in server/src/routes/printRoutes.ts.
POST /api/print/receipt
Request a receipt print job by local order id (ORD-... or WOO-...).
Body: { orderId: string }
- 202:
{ jobId } - 400:
{ error: 'orderId is required' } - 404:
{ error: 'Order not found' } - 500:
{ error, details }
Defined in server/src/routes/printRoutes.ts.
GET /api/print/jobs/:jobId
Poll a print job status.
- 200:
{ jobId, status, job_type, printer_route, error_message, updated_at } - 404:
{ error: 'Print job not found' }
Defined in server/src/routes/printRoutes.ts.
POST /api/print/jobs
Low-level enqueue endpoint (generic print job).
Body: { job_type: string, printer_route: string, template_name: string, context?: object }
- 202:
{ jobId } - 400:
{ error: 'job_type, printer_route, and template_name are required' } - 500:
{ error, details }
Defined in server/src/routes/printRoutes.ts.
Catalog / Sync operations
POST /api/catalog/bootstrap
Runs initial bootstrap (downloads catalog + customers) if not completed yet.
- 200:
{ success: true } - 409:
{ error: 'Bootstrap already completed' } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
POST /api/catalog/re-bootstrap
Guarded re-bootstrap. Requires confirm token.
Body: { confirm: string } (must be REBOOTSTRAP)
- 200:
{ success: true, warnings: string[] } - 400:
{ error: string }(missing/wrong confirm token) - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
POST /api/sync/products
Pull products from Woo (restricted to bootstrap context unless bootstrap_context is set).
Body: { bootstrap_context?: boolean }
- 200:
{ success: true, message } - 403:
{ error: 'Product pull is restricted...' } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
Sync
GET /api/sync/status
Operator diagnostics: bootstrap flag, order poll cursor, last push timestamps, pending queue depths.
- 200:
{ bootstrap_completed, order_poll_cursor, last_catalog_push, last_customer_push, pending_sync_jobs, pending_print_jobs } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
POST /api/sync/push-catalog
Push full local catalog to Woo.
- 200:
{ success: true, products_pushed: number } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
POST /api/sync/push-customers
Push customers to Woo.
- 200:
{ success: true, customers_pushed: number } - 500:
{ error, details }
Defined in server/src/routes/catalogRoutes.ts.
Realtime (Socket.io)
Socket.io server is attached to the same HTTP server; Thin Clients connect and receive broadcasts.
Notable event emitted by server:
order_upserted(emitted after Till checkout and during Woo ingestion)
Defined in server/src/index.ts and server/src/services/RealtimeBroadcaster.ts.