Skip to main content
POST
/
chat-messages
Send Agent App Message
curl --request POST \
  --url https://{api_base_url}/chat-messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "inputs": {
    "customer_tier": "enterprise"
  },
  "query": "Summarize the attached product feedback and suggest next steps.",
  "response_mode": "streaming",
  "conversation_id": "",
  "user": "user-123",
  "files": [
    {
      "type": "document",
      "transfer_method": "local_file",
      "upload_file_id": "72fa9618-8f89-4a37-9b33-7e1178a24a67"
    }
  ]
}
'
"data: {\"event\": \"agent_thought\", \"id\": \"agent_thought_id_1\", \"task_id\": \"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"position\": 1, \"thought\": \"Thinking about calling a tool...\", \"tool\": \"dalle3\", \"tool_input\": \"{\\\"dalle3\\\": {\\\"prompt\\\": \\\"a cute cat\\\"}}\", \"created_at\": 1705395332} data: {\"event\": \"message_file\", \"task_id\": \"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"id\": \"file_id_1\", \"type\": \"image\", \"belongs_to\": \"assistant\", \"url\": \"https://example.com/cat.png\", \"created_at\": 1705395332} data: {\"event\": \"agent_message\", \"task_id\": \"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"answer\": \"Here is the image: \", \"created_at\": 1705395333} data: {\"event\": \"message_end\", \"task_id\":\"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"metadata\": {\"usage\": {\"total_tokens\": 50, \"latency\": 2.5}}}"

Authorizations

Authorization
string
header
required

API Key authentication. For all API requests, include your API Key in the Authorization HTTP Header, prefixed with Bearer. Example: Authorization: Bearer {API_KEY}. Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.

Body

application/json

Request body to send an Agent app message.

Request body for sending a message to an Agent app.

query
string
required

User message or task for the Agent app.

inputs
object
required

Values for variables configured in the Agent Soul. Call the Get Agent App Parameters API to discover expected variable names and input controls.

user
string
required

End-user identifier, unique within this Agent app. Conversations, messages, and uploaded files are scoped to the same user value.

response_mode
enum<string>
default:streaming

Agent apps support streaming mode only. Set this field to streaming or omit it.

Available options:
streaming
conversation_id
string

Conversation ID to continue. Omit this field or pass an empty string to start a new conversation, then reuse the returned conversation_id in later requests.

files
object[]

Files for multimodal Agent input. To attach a local file, upload it with the Upload File API first, then pass the returned file id as upload_file_id with transfer_method: local_file.

auto_generate_name
boolean
default:true

Auto-generate conversation title. If false, use the Rename Conversation API with auto_generate: true for async title generation.

Response

Successful streaming response. Agent apps return text/event-stream Server-Sent Events. Blocking JSON responses are not supported for Agent apps.

A stream of Server-Sent Events (SSE).

Parsing: Each event is a line prefixed with data: followed by a JSON object, terminated by \n\n. Strip the data: prefix before parsing the JSON, then read the event field to determine the event type. Ignore ping events, which arrive as event: ping lines (no data: payload) every 10 seconds to keep the connection alive.

Stream lifecycle: The reply streams as message events (Chatbot apps), or as agent_thought and agent_message events (Agent apps), and ends with message_end. When text-to-speech auto-play is enabled, tts_message events interleave and tts_message_end becomes the final event.

Events: Apart from ping, every event includes conversation_id, message_id, and created_at (Unix epoch seconds); all but error also include task_id.

Reply events

EventAppFires onKey fields
messageChatboteach answer chunk (concatenate in order)answer
agent_messageAgenteach answer chunk (concatenate in order)answer
agent_thoughtAgenteach reasoning or tool-call stepposition, thought, tool, tool_input (JSON), observation, message_files
message_replaceChatbot, Agentoutput moderation replaces the answer so faranswer
message_fileChatbot, Agentthe assistant returns a filetype, belongs_to, url
message_endChatbot, Agentthe answer is completemetadata (usage, retriever_resources)
tts_message, tts_message_endChatbot, Agentaudio chunk / end, when TTS auto-play is onaudio

Transport events

EventAppFires onKey fields
errorChatbot, Agenta failure ends the stream; HTTP stays 200status (e.g. 400), code (e.g. invalid_param), message
pingChatbot, Agentkeep-alive every 10 secondsnone
Last modified on July 2, 2026