Skip to main content

API Overview

The Desktop Kitchen POS exposes a REST API for all operations. This overview covers the API structure for developers and integrations.

Base URL

https://pos.desktop.kitchen/api

For tenant-specific access, include the X-Tenant-ID header or use the tenant's subdomain.

Authentication

The API uses two authentication systems:

Employee PIN Auth

For POS operations (orders, payments, menu queries):

  • Header: x-employee-id: <employee_id>
  • Used by the POS frontend

Owner JWT Auth

For tenant management and billing:

  • Header: Authorization: Bearer <jwt_token>
  • Obtain tokens via POST /api/auth/login

API Routes

MethodEndpointDescription
GET/api/menu/categoriesList all categories
GET/api/menu/itemsList all menu items
POST/api/menu/itemsCreate a menu item
PUT/api/menu/items/:idUpdate a menu item
DELETE/api/menu/items/:idDelete a menu item

Orders

MethodEndpointDescription
GET/api/ordersList orders
POST/api/ordersCreate an order
PUT/api/orders/:id/statusUpdate order status
GET/api/orders/:idGet order details

Payments

MethodEndpointDescription
POST/api/payments/create-intentCreate Stripe PaymentIntent
POST/api/payments/refundRefund a payment

Inventory

MethodEndpointDescription
GET/api/inventoryList inventory items
POST/api/inventoryAdd inventory item
PUT/api/inventory/:idUpdate stock

Employees

MethodEndpointDescription
GET/api/employeesList employees
POST/api/employeesCreate employee
POST/api/employees/loginPIN login

Reports

MethodEndpointDescription
GET/api/reports/salesSales summary
GET/api/reports/itemsItem performance

Delivery

MethodEndpointDescription
GET/api/delivery/platformsList platforms
GET/api/delivery/markup-rulesList markup rules
GET/api/delivery-intelligence/pnlP&L analytics

Loyalty

MethodEndpointDescription
GET/api/loyalty/customersList customers
GET/api/loyalty/configLoyalty configuration

Branding

MethodEndpointDescription
GET/api/brandingGet tenant branding
PUT/api/brandingUpdate branding

Response Format

All endpoints return JSON:

// Success
{
"id": 1,
"name": "Taco al Pastor",
"price": 45.00
}

// Error
{
"error": "Item not found"
}

Admin (Super Admin) API

These endpoints are mounted before tenant middleware and protected by the ADMIN_SECRET header. They use the admin connection pool (neondb_owner) which bypasses RLS.

info

Admin routes are not tenant-scoped. They operate across all tenants and require x-admin-secret header authentication instead of employee PIN or owner JWT.

MethodEndpointDescription
GET/admin/analytics/overviewPlatform-wide KPIs (tenants, MRR, churn)
GET/admin/analytics/signupsSignup trends over time
GET/admin/analytics/revenueRevenue breakdown by plan
GET/admin/analytics/healthSystem health metrics
GET/admin/tenantsList all tenants
POST/admin/tenantsCreate a new tenant
PATCH/admin/tenants/:idUpdate tenant details
DELETE/admin/tenants/:idDelete tenant and all data
POST/admin/tenants/:id/seedSeed tenant with demo data
POST/admin/tenants/:id/reset-passwordReset tenant owner password
GET/admin/tenants/:id/exportExport all tenant data as JSON
GET/admin/tenants/:id/activityRecent tenant activity
GET/admin/configPlatform configuration
PUT/admin/configUpdate platform configuration
GET/admin/audit-logAdmin action audit trail
POST/admin/impersonate/:idImpersonate a tenant (debug)

Multi-Tenancy

All tenants share a single Neon Postgres database, isolated by Row Level Security (RLS). Every tenant-scoped table has a tenant_id column with RLS policies that filter rows based on current_setting('app.tenant_id').

Tenant resolution happens automatically via:

  1. X-Tenant-ID header (highest priority)
  2. Subdomain (e.g., yourrestaurant.desktop.kitchen)
  3. DEFAULT_TENANT_ID environment variable
  4. Default fallback

The backend maintains two connection pools:

  • adminSql (neondb_owner) — bypasses RLS, used for auth routes, admin API, and AI background jobs
  • tenantSql (app_user) — enforces RLS, used for all tenant-scoped /api/* routes

Tax

All prices are in MXN. Tax (16% IVA) is calculated at order creation, not stored on items.

note

Full API reference documentation with request/response schemas will be available in a future update. This overview covers the primary endpoints.