Chat API

This page documents the API endpoints for managing chat conversations and messages with AI Employees.

CreateConversation

Create a new conversation with an AI Employee.

PropertyValue
URL/api/chat/
HTTP MethodPOST
ProtocolREST (HTTP/JSON)

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token
Content-TypestringYesapplication/json

Request Body

FieldTypeRequiredDescription
persona_idstringYesUUID of the AI Employee to chat with
user_contextobjectNoFree-form context map merged into every message in the conversation
callerstringNoIdentifier of the calling integration (for analytics)

Example

curl -X POST https://your-instance.ema.co/api/chat/ \
 -H "Authorization: Bearer <access_token>" \
 -H "Content-Type: application/json" \
 -d '{
 "persona_id": "abc12345-6789-0abc-def0-123456789abc"
 }'

Response

FieldTypeDescription
conversation_idstringUUID of the created conversation
messageobjectThe opening ChatbotMessage (e.g. welcome message)
snippetsarraySource snippets cited by the opening message, if any

RespondToMessage (Synchronous)

Send a user message and receive an AI response synchronously.

PropertyValue
URL/api/chat/{conversation_id}
HTTP MethodPOST
ProtocolREST (HTTP/JSON)

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeDescription
conversation_idstringUUID of the conversation

Request Body

FieldTypeRequiredDescription
messageobjectYesA ChatbotMessage object (must include at least content). See Chat Data Model for the full shape.
user_contextobjectNoPer-message context merged with any conversation-level context
original_message_idstringNoID of the original message when this is a retry / regeneration
impersonation_requestobjectNoFor admin-impersonated calls

Example

curl -X POST https://your-instance.ema.co/api/chat/<conversation_id> \
 -H "Authorization: Bearer <access_token>" \
 -H "Content-Type: application/json" \
 -d '{
 "message": { "content": "How do I reset my password?" }
 }'

Response

FieldTypeDescription
conversation_idstringUUID of the conversation
messageobjectThe assistant's reply, as a ChatbotMessage
snippetsarraySource snippets cited by the reply

RespondToMessage (Asynchronous)

Send a user message without waiting for the AI response. Returns immediately with a placeholder message id; poll GetMessages to retrieve the assistant's reply when ready.

PropertyValue
URL/api/chat/{conversation_id}/async
HTTP MethodPOST
ProtocolREST (HTTP/JSON)

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeDescription
conversation_idstringUUID of the conversation

Request Body

Same shape as RespondToMessage (Synchronous).

Example

curl -X POST https://your-instance.ema.co/api/chat/<conversation_id>/async \
 -H "Authorization: Bearer <access_token>" \
 -H "Content-Type: application/json" \
 -d '{
 "message": { "content": "Generate a summary report for Q4 sales" }
 }'

Response

HTTP 202 with body:

FieldTypeDescription
placeholder_message_idstringID of the placeholder message; use this with GetMessages to retrieve the assistant's reply when ready.

GetMessages

Retrieve all messages in a conversation.

PropertyValue
URL/api/chat/{conversation_id}
HTTP MethodGET
ProtocolREST (HTTP/JSON)

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token

Path Parameters

ParameterTypeDescription
conversation_idstringUUID of the conversation

Example

curl -X GET https://your-instance.ema.co/api/chat/<conversation_id> \
 -H "Authorization: Bearer <access_token>"

Response

FieldTypeDescription
messagesarrayArray of ChatbotMessage objects, in chronological order

GetChatbotConfig

Retrieve the chatbot configuration for a specific AI Employee.

PropertyValue
URL/api/chat/config/{persona_id}
HTTP MethodGET
ProtocolREST (HTTP/JSON)

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token

Path Parameters

ParameterTypeDescription
persona_idstringUUID of the AI Employee

Example

curl -X GET https://your-instance.ema.co/api/chat/config/<persona_id> \
 -H "Authorization: Bearer <access_token>"

Response

Returns the chatbot configuration including welcome message, suggested questions, branding, and display settings.

LogCustomEvent

Log a custom event for analytics tracking in a chatbot session.

PropertyValue
URL/api/chat/events
HTTP MethodPOST
ProtocolREST (HTTP/JSON)

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token
Content-TypestringYesapplication/json

Request Body

FieldTypeRequiredDescription
event_namestringYesName of the custom event
occurred_atstring (ISO-8601 datetime)YesWhen the event occurred
conversation_idstringYesUUID of the conversation the event belongs to
message_idstringYesID of the message the event references
metadataobjectNoAdditional event data

Response

FieldTypeDescription
successbooleantrue if the event was logged

Last updated: Jul 3, 2026