Customer Chat API
The Customer Chat API lets your backend create conversations and exchange messages with the support agent on behalf of your users.
Authentication
All requests require a customer API key (lxc_ prefix) in the Authorization header:
Authorization: Bearer lxc_...
Customer API keys are server-side secrets. Do NOT embed them in client-side JavaScript or mobile app bundles. We recommend proxying requests through your application backend.
Base URL
https://lexey.ai/api/v1/customer
Quick start
1. Create a conversation:
| 1 | curl -X POST https://lexey.ai/api/v1/customer/conversations \ |
| 2 | -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \ |
| 3 | -H "Content-Type: application/json" |
Response: { "conversationId": "550e8400-..." }
2. Send a message (streamed response):
| 1 | curl -N -X POST https://lexey.ai/api/v1/customer/conversations/CONVERSATION_ID/messages \ |
| 2 | -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \ |
| 3 | -H "Content-Type: application/json" \ |
| 4 | -d '{"message": "What are your business hours?"}' |
3. Retrieve message history:
| 1 | curl https://lexey.ai/api/v1/customer/conversations/CONVERSATION_ID/messages \ |
| 2 | -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" |
SSE stream format
The send message endpoint returns text/event-stream. Each event includes a monotonically incrementing id: field and a data: line:
id: 1\ndata: {"type":"delta","text":"chunk"}— incremental text, append to the responseid: N\ndata: {"type":"status","status":"escalated"}— conversation state changeid: N\ndata: [DONE]— stream complete
For code examples in TypeScript, Python, Go, Ruby, and C#, see the Streaming guide.
Error codes
| Status | Meaning |
|---|---|
| 400 | Invalid request (e.g. message too long) |
| 401 | Missing or invalid API key |
| 402 | No active subscription or credits exhausted |
| 403 | Wrong key type (use lxc_ key) |
| 404 | Conversation not found |
| 429 | Conversation message limit reached |
| 500 |