Vexar API

Chat (widget)

These are the public endpoints the chat widget uses. They need no token — they are scoped by site_key + session_id. The main chat endpoint streams the AI reply via Server-Sent Events.

POST /api/v1/chat/stream Public

Send a visitor message and stream the AI answer as text/event-stream (SSE). Each event is a JSON chunk; a final event carries conversation_id.

Request body
{
  "site_key": "sk_…",
  "session_id": "sess_…",
  "message": "Do you ship to Canada?",
  "lang": "en",
  "message_id": "m_abc"
}
Response
data: {"type":"chunk","content":"Yes, "}
data: {"type":"chunk","content":"we do."}
data: {"type":"done","meta":{"conversation_id":50}}
GET /api/v1/chat/history Public

Conversation history for a session.

Response
{ "success": true, "messages": [ … ] }
POST /api/v1/chat/email Public

Save the visitor’s email to the conversation.

Request body
{ "site_key": "sk_…", "session_id": "sess_…", "email": "[email protected]" }
Response
{ "success": true, "message": "Email saved" }
POST /api/v1/chat/contact Public

Save a contact (email and/or phone, optional name).

Request body
{ "site_key": "sk_…", "session_id": "sess_…", "email": "[email protected]", "phone": "+1…", "name": "Jane" }
Response
{ "success": true, "message": "Contact saved" }
GET /api/v1/chat/operator-messages Public

New operator messages and the current mode (ai | operator).

Response
{ "success": true, "messages": [ … ], "mode": "operator" }
GET /api/v1/chat/block-status Public

Whether the visitor is blocked.

Response
{ "success": true, "blocked": false }
GET /api/v1/chat/pending-proactive Public

Pending proactive (nudge) messages for the session.

Response
{ "success": true, "messages": [ … ] }
POST /api/v1/chat/upload-image Public

Upload an image from the widget (multipart field image).

Response
{ "success": true, "url": "https://cdn…" }
POST /api/v1/chat/rate Public

Rate the conversation (1–5).

Request body
{ "site_key": "sk_…", "session_id": "sess_…", "score": 5 }
Response
{ "success": true }
POST /api/v1/chat/rate/comment Public

Add a comment to a rating.

Request body
{ "site_key": "sk_…", "session_id": "sess_…", "comment": "Great!" }
Response
{ "success": true }