Skip to main content
All chat endpoints are under the /api/chat prefix. Streaming responses use newline-delimited JSON (NDJSON) over text/event-stream.

Create a chat session

Creates a new chat session and returns its ID. You must create a session before sending messages to it, or pass chat_session_info inline in send-chat-message to create a session implicitly.

Request body

integer
default:"0"
ID of the agent (persona) to use for this session. Defaults to 0 (the default Hadiq.io assistant).
string
Optional human-readable name for the session.
integer
Optional project ID to associate the session with.

Response

string (UUID)
Unique identifier for the new session.

Send a chat message

Sends a message in a chat session. When stream is true (the default), the response is a streaming text/event-stream of NDJSON packets. When stream is false, the full response is returned as a single JSON object.

Request body

string
required
The user message to send.
string (UUID)
ID of an existing session. Provide either chat_session_id or chat_session_info, not both.
object
Create a session implicitly alongside the message. Provide either this or chat_session_id, not both.
boolean
default:"true"
When true, returns a streaming text/event-stream. When false, returns a complete ChatFullResponse JSON object.
integer
default:"-1"
Placement of the new message in the conversation tree. -1 appends after the latest message. null regenerates from the root.
object
Override the LLM model for this message.
boolean
default:"true"
When false, citation markers and CitationInfo packets are suppressed.
object
Optional filters to restrict which documents are searched.
array
Uploaded files to attach to the message.
string
Extra context injected into the LLM call but not stored in chat history.
boolean
default:"false"
Enable deep research mode for more thorough retrieval.

Streaming response

Each event is a NDJSON line representing one packet in the response stream. Packet types include answer tokens, citations, search results, and tool call info.

Non-streaming response (stream: false)

string
The complete assistant answer.
integer
ID of the created assistant message.
object
Search results used to generate the answer.
object
Map of citation number to document ID.
The correct path is /api/chat/send-chat-message (note: send-chat-message, not send-message).

Get a chat session

Returns the full history of a session including all messages.

Path parameters

string (UUID)
required
The session to retrieve.

Query parameters

boolean
default:"false"
Set to true to retrieve a publicly shared session without authentication.
boolean
default:"false"
Include sessions that have been soft-deleted.

Response

string (UUID)
Session identifier.
string
Session name or description.
integer
Agent associated with this session.
string
Display name of the agent.
array
Ordered list of messages in the session.
string (ISO 8601)
When the session was created.
string
Sharing state: private or public.

List chat sessions

Returns a paginated list of the authenticated user’s chat sessions.

Query parameters

integer
default:"50"
Number of sessions per page. Minimum 1, maximum 100.
string (ISO 8601)
Cursor for pagination. Pass the time_created of the last session from the previous page to fetch older sessions.
integer
Filter by a specific project.
boolean
default:"true"
When true, excludes sessions that belong to a project.
boolean
default:"false"
Include sessions that ended in an error state.

Response

array
List of session summaries.
boolean
Whether more sessions are available. Use the time_created of the last session as before for the next page.

Delete a chat session

Deletes a chat session. By default, performs a soft delete (recoverable). Pass hard_delete=true to permanently remove the session.

Path parameters

string (UUID)
required
The session to delete.

Query parameters

boolean
When true, permanently deletes the session and all its messages. When omitted, the default behavior is controlled by your instance’s deletion policy.
Returns 204 No Content on success.

Stop a running chat session

Signals the server to stop generating a response for a streaming session (equivalent to clicking “Stop” in the UI).

Path parameters

string (UUID)
required
The session whose generation to stop.
Returns {"message": "Chat session stopped"}.

Error codes