Endpoints

Chat

API reference for the Chat API — manage sessions, send messages, and receive streaming AI responses.

Overview

The Chat API powers conversations between end users and your AI agent. There are two sets of endpoints: Public endpoints (authenticated via X-API-Key header, for embed widgets and custom UIs) and Internal endpoints (authenticated via JWT, for the dashboard debug/preview mode). Public endpoints are served by the Agent Service at /public/chatbot/*.

Get Chatbot Config

GET /public/chatbot/config — Retrieve the public chatbot configuration. Auth: X-API-Key header. Returns: { id, name, avatarUrl, welcomeMessage, suggestedQuestions, theme, features, branding }. Use this to initialize your custom chat UI with the correct branding and feature toggles.

Start Session

POST /public/chatbot/sessions — Initialize a new chat session. Auth: X-API-Key header. Body: { visitorId?: string, user?: { name, email }, metadata?: object }. Returns: { sessionId: string, welcomeMessage?: string, suggestedQuestions?: string[] }. The session is linked to the chatbot associated with the API key.

Send Message

POST /public/chatbot/sessions/{sessionId}/messages — Send a user message. Auth: X-API-Key header. Body: { message: string, metadata?: object }. Returns: { sessionId, userMessage, assistantMessage, status, metadata (with sources), createdAt }. The response is generated by executing the published workflow for the chatbot.

Streaming Responses

POST /public/chatbot/sessions/{sessionId}/stream — Stream the AI response via Server-Sent Events (SSE). Auth: X-API-Key header. Body: { message: string }. Events: "start" (session started), "chunk" (response token with content field), "end" (generation complete with metadata). The stream uses text/event-stream content type.

Session Management

GET /public/chatbot/sessions/{sessionId} — Get session info (creation time, last activity, message count, metadata). DELETE /public/chatbot/sessions/{sessionId} — Clear session history. Sessions also auto-expire after inactivity, triggering the timeout workflow configured in the chatbot.

Debug Mode (Internal)

Debug endpoints are available via the Automation Service for authenticated users: POST /chat/debug/start — Start a debug session with full execution tracing. POST /chat/debug/{sessionId}/message — Send a debug message with card-by-card execution logs. GET /chat/debug/{sessionId}/variables — View current variable context. Debug mode is used in the dashboard Playground for testing workflows during development.