- SDK API (
/api/sdk/v1/) — For frontend and mobile apps. Authenticates with a client identifier and validates the request origin. Supports SSE streaming for real-time responses. - Public API v1 (
/api/v1/) — For server-to-server integrations. Authenticates with an API key. Use this when your backend needs to send messages or manage conversations programmatically.
Authentication
SDK API (Frontend / Mobile)
Every request to/api/sdk/v1/ requires these headers:
Public API v1 (Server-to-Server)
Every request to/api/v1/ requires a single header:
SDK API Endpoints
Send Message
POST /api/sdk/v1/messages
Sends a message and returns an SSE streaming response.
Request body:
content is required. Omit conversation_id to start a new conversation.
Response: Server-Sent Events stream (see SSE Streaming below).
Get Message Status
GET /api/sdk/v1/messages/{message_id}/status
Poll this endpoint when SSE streaming is not available. Returns the current processing status and any content generated so far.
Submit Feedback
POST /api/sdk/v1/messages/{message_id}/feedback
"positive" or "negative".
List Conversations
GET /api/sdk/v1/conversations
Returns a paginated list of conversations for the current user.
Response:
Get Conversation
GET /api/sdk/v1/conversations/{conversation_id}
Returns a single conversation with its full message history.
Unread Count
GET /api/sdk/v1/conversations/unread
Returns the number of unread conversations.
Widget Config
GET /api/sdk/v1/config
Returns widget configuration and available forms.
Integration Patterns
SSE Streaming (Recommended)
The send-message endpoint returns a Server-Sent Events stream. Each event is a JSON object on adata: line.
Polling Fallback
If SSE is blocked by firewalls or proxies, poll the message status endpoint instead:Conversation Management
Useconversation_id to maintain multi-turn conversations:
Public API v1 (Server-to-Server)
Use the Public API when your backend needs to send messages on behalf of users or automate workflows.Send Message
POST /api/v1/send-message
Best Practices
- Stream responses to users as they arrive. Do not wait for the full response before displaying content.
- Set timeouts to 60+ seconds for streaming connections. AI responses can take time depending on the query.
- Store
conversation_idfrom the first response and pass it back on subsequent messages to maintain context. - Never expose
X-API-Keyin frontend code. The Public API is for server-to-server use only. Use the SDK API (X-User-Anon-Id) for frontend apps. - Implement retry with backoff for transient errors (5xx, network timeouts).
Troubleshooting
Related Documentation
- Widget Authentication — Token setup for frontend apps
- API Key Authentication — API key management
- Portal Integration — Full web portal alternative
