API reference
HTTP-first. JSON in, JSON out.
Every dashboard action is also an endpoint. Auth via the bearer token from your Account → API keys page (coming soon, for now use Supabase auth cookies).
Auth
Most endpoints are agent-scoped: they read the logged-in agent\'s user_id and resolve org_id from the agents table. Browser-based callers use the Supabase auth cookie (no manual header needed). Server-to-server callers should hit the upcoming Bearer ${token} path.
Widget endpoints (/api/widget/*, /api/chat) are intentionally public-CORS so the embedded widget can reach them from any host. They scope all data by org_id + visitor_id.
Sessions
/api/sessionsCreate or resume a chat session for a visitor.
/api/sessions?sessionId=…Read messages + session meta + agent typing state.
/api/sessions/endClose a session.
Messages + AI
/api/chatSend a customer message and stream the AI reply.
/api/messagesAgent posts a reply into a session.
Visitor + cart
/api/visitor-pingHeartbeat to keep widget_visitors alive.
/api/widget/cart?orgId=…Rehydrate the visitor's Shopify cart card.
/api/widget/cart/lineMutate one line in the cart (qty change or remove).
Broadcasts + triggers
/api/sessions/cold-chat/broadcastSend one message to all live visitors right now.
/api/scheduled-broadcastsList scheduled broadcasts.
/api/scheduled-broadcastsCreate one.
/api/scheduled-broadcasts/:idUpdate one.
/api/scheduled-broadcasts/:idDelete one.
/api/scheduled-broadcasts/:idRun now (manual trigger).
Canned shortcuts
/api/canned-responsesList the org's saved shortcuts.
/api/canned-responsesCreate a shortcut.
/api/canned-responses/:idEdit a shortcut.
/api/canned-responses/:idDelete a shortcut.
Widget config
/api/widget-config?propertyId=…Public, returns the customer-facing widget config (color, palette, behavior toggles, etc.).
Rate limits
Free plan: 60 requests/minute per org. Pro: 600/min. Enterprise: custom. Limits are per-endpoint and reset every 60s. Hitting the limit returns 429 Too Many Requests with a Retry-After header.