Messages
Send messages to the AI agent and retrieve message history.
The messages endpoints are the core of the Headless Chat API. Send a user message and receive an AI response powered by the agent's knowledge base.
Send a Message
Sends a user message to the AI agent and returns the AI response. The agent uses RAG (Retrieval-Augmented Generation) to find relevant content from its knowledge base before generating a response.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
agentId | string (UUID) | Yes | The agent ID |
sessionId | string (UUID) | Yes | The session ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The user's message |
additionalContext | string | No | Extra context (e.g. page content) to help the AI generate a more relevant response |
format | "markdown" | "html" | No | Response format. Default: "markdown" |
Response
Response Fields
| Field | Type | Description |
|---|---|---|
chatSession | object | Session ID and name |
userMessage | object | The saved user message with its ID and timestamp |
aiMessage | object | The AI response with content, model used, and timestamp |
aiMessage.model | string | The LLM model used (e.g. "gpt-4o-mini") |
followUps | array | Suggested follow-up questions (if enabled on the agent) |
followUps[].text | string | The suggested question |
followUps[].confidence | number | Confidence score (0–1) |
Code Examples
Get Message History
Returns paginated message history for a chat session.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
cursor | string (UUID) | — | Message ID to start after (for pagination). Omit for the first page. |
limit | integer | 50 | Messages per page (min: 1, max: 100) |
Response
Pagination
Use cursor-based pagination to navigate through large message histories: