API Endpoint
application/json or multipart/form-data (when files are included)
Response Format: Server-Sent Events (SSE) stream
Overview
The send message API allows you to:- Start new conversations with AI agents
- Continue existing conversation threads
- Upload file attachments (PDF, images, documents)
- Receive real-time streaming responses
- Use background agents for long-running tasks
- Specify agent or use permission-based agent selection
Request Parameters
Query Parameters
If neither
agent_id nor permission_id is provided, the system will use the user’s default agent. Even if an agent_id is provided, the system will verify that the user has permission to use that agent.Request Body (JSON)
The simplest request body is:thread object:
Body Fields
IsStaff sets the message role to “Staff”. We use it when a human staff member is sending the message, otherwise the role is “user”. Languages are used to return document titles and other metadata in the user’s preferred language.
Request Body (FormData with Files)
When uploading files, usemultipart/form-data format:
- message: JSON string containing the message data (same structure as JSON body above)
- files: One or more file uploads (max 5 files, 10MB each)
Response Format
The API returns a Server-Sent Events (SSE) stream with multiple event types:1. Agent and Thread Information
First event sent when starting a conversation:2. Knowledge Sources
Sources used by the agent to answer the question:3. Streaming Content
Incremental content chunks as the agent generates the response:4. Completion Status
Final event when the response is complete:5. Thread Title Generation
Automatic title generation for new threads:Response Status Values
Background Agents
When using a background agent (for long-running tasks):- The initial response confirms the background task has started
- Use the progress stream endpoint to monitor status
- The agent will process the request asynchronously
- Progress updates are stored in the message’s
background_agent_progressfield
Usage Examples
Basic Request - Start New Conversation
Continue Existing Conversation
Send Message to Specific Agent
Send Message with File Attachments
Use Permission-Based Agent Selection
JavaScript/TypeScript Example with SSE
Monitoring Background Agents
For background agents, use the progress stream endpoint to monitor execution:Progress Stream Events
Fallback Polling System
If streaming fails or is not supported (some mobile environments, proxies), use the message status endpoint for polling.When to Use Polling
- SSE connection fails or times out
- Behind proxy that doesn’t support streaming
- Mobile SDK with limited SSE support
- Testing/debugging scenarios
Message Status Endpoint
Polling Implementation
Poll every 1-2 seconds untilstatus is DONE or ERROR:
Polling Best Practices
Error Responses
400 Bad Request - Invalid Request Body
400 Bad Request - Invalid UUID Format
403 Forbidden - File Attachments Disabled
400 Bad Request - File Too Large
400 Bad Request - Too Many Files
400 Bad Request - Invalid File Type
404 Not Found - Agent Not Found
Integration Notes
Agent Selection Priority
The system selects an agent in this order:- agent_id parameter (if provided) - highest priority
- permission_id parameter (selects default agent for that permission)
- User’s default agent (fallback)
Message Processing Flow
- User message is saved to the database
- Agent is selected based on parameters
- File attachments are validated and stored (if present)
- For background agents: task is queued for async processing
- For standard agents:
- Relevant documents are retrieved from knowledge base
- Documents are reranked if enabled
- Additional context is added to the prompt
- Response is streamed back via SSE
- Assistant message is saved with sources and status
- Thread title is generated for new conversations
