Lexey
Use casesPricingDocs
Sign inGet started
Get started
  • Use cases
  • Pricing
  • Docs
  • Sign in
Customer Chat API
Basics
  • Getting started
  • The portal
Features
  • Working with Lexey
  • Knowledge base
  • Conversations
  • Customer chat
  • Skills & automations
  • Testing and releases
  • Quality assurance
  • AI safety
  • Billing & usage
Deployment
  • Embedding your chat
API
  • Customer Chat API
  • Management Chat API
  • Webhook events
  • API key management
  • Streaming guide
  • Agent integration
Help
  • FAQ
API/Customer Chat API

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_...
Caution

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:

1curl -X POST https://lexey.ai/api/v1/customer/conversations \
2 -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \
3 -H "Content-Type: application/json"

Response (201): { "conversationId": "550e8400-...", "mode": "live" }

2. Send a message (streamed response):

1curl -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:

1curl https://lexey.ai/api/v1/customer/conversations/CONVERSATION_ID/messages \
2 -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY"

Response: { "messages": [{ "role": "user" | "assistant", "content": "...", "createdAt": "..." }] }

Shadow mode

To try Lexey on real customer messages without it acting on them, create the conversation in shadow mode:

1curl -X POST https://lexey.ai/api/v1/customer/conversations \
2 -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{"mode": "shadow"}'

The agent answers as usual, but escalation emails and webhooks are only recorded, never sent. Your API connector still makes its read-only calls. Shadow conversations appear in Conversations marked Shadow. Use it to run Lexey alongside your current support and compare its answers before you go live. A mode other than "live" or "shadow" is rejected with 400; an empty body is live.

Tell Lexey who the customer is

If your app knows who is signed in, pass it when you create the conversation. The agent then doesn't ask for details it already has, and an escalation reaches your team with them:

1curl -X POST https://lexey.ai/api/v1/customer/conversations \
2 -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{"customer": {"identifier": "user-8812", "name": "Aroha Smith", "email": "aroha@example.com", "phone": "+64 21 555 0100"}}'

Every field is optional. identifier is your own ID for the customer and appears in webhooks and the Management API as customerIdentifier. Escalation emails show the name, email and phone instead, and fall back to identifier only when none of them is on file. name, email and phone are saved as the conversation's contact details, the same ones the Collect contact information skill saves. When every field that skill requires is already on file, the agent escalates without asking for them. Text fields are up to 200 characters, email must be an email address and phone may contain only digits, spaces and + ( ) - .. Anything else, including an unknown field, is rejected with 400. customer works with mode in the same body.

Check a key

GET /api/v1/customer/identity returns the key's organization without starting a conversation or using credits: { "tenantId": "...", "type": "customer", "environment": "production", "expiresAt": null }.

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 response
  • id: N\ndata: {"type":"response_options","options":[...],"displayMode":"buttons"} — choices the agent offers, after the text (only when the Interactive response options skill is on)
  • id: N\ndata: {"type":"error","message":"..."} — an error after streaming began
  • id: N\ndata: [DONE] — stream complete

For code examples in TypeScript, Python, Go, Ruby, and C#, see the Streaming guide.

Error codes

StatusMeaning
400Invalid request (e.g. a message over 3,000 characters, an unknown mode, or an invalid customer field)
401Missing or invalid API key
402No active subscription or credits exhausted
403Wrong key type (use lxc_ key)
404Conversation not found
429The conversation reached 100 messages (code: "CONVERSATION_LIMIT_REACHED"), or too many requests
500Internal server error
← Previous: Embedding your chatNext: Management Chat API →
On this pageAuthenticationBase URLQuick startShadow modeTell Lexey who the customer isCheck a keySSE stream formatError codes
Lexey

Lexey learns your business from your website and answers customers around the clock.

ProductFeaturesPricingUse casesCompareGuides
DocsGetting startedCustomer APIManagement API
AccountSign upSign in
© 2026 Lexey
TermsTerms of servicePrivacyPrivacy policy