curl --request POST \
--url https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Namespace: <api-key>' \
--data '
{
"content": "Find videos about machine learning",
"metadata": {
"source": "web_app"
},
"stream": true
}
'import requests
url = "https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages"
payload = {
"content": "Find videos about machine learning",
"metadata": { "source": "web_app" },
"stream": True
}
headers = {
"Authorization": "Bearer <token>",
"X-Namespace": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'X-Namespace': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: 'Find videos about machine learning',
metadata: {source: 'web_app'},
stream: true
})
};
fetch('https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'content' => 'Find videos about machine learning',
'metadata' => [
'source' => 'web_app'
],
'stream' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Namespace: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages"
payload := strings.NewReader("{\n \"content\": \"Find videos about machine learning\",\n \"metadata\": {\n \"source\": \"web_app\"\n },\n \"stream\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Namespace", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages")
.header("Authorization", "Bearer <token>")
.header("X-Namespace", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"Find videos about machine learning\",\n \"metadata\": {\n \"source\": \"web_app\"\n },\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Namespace"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"Find videos about machine learning\",\n \"metadata\": {\n \"source\": \"web_app\"\n },\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}Send Message
Send a message to the agent and stream the response.
This endpoint streams Server-Sent Events (SSE) back to the client as the agent processes the message through its workflow.
SSE Event Types
Core Events:
intent: Intent classification result (emitted first){intent, confidence, category, reasoning, context_scope}
thinking: Agent is analyzing/planning{step, message}
tool_call: Agent is calling a tool{tool_name, tool_call_id, inputs}
tool_result: Tool execution completed{tool_name, tool_call_id, success, output, latency_ms}
token: Response token (streaming){content}
message: Final response content{content, message_id, is_final}
session_name: Auto-generated session name (first message only){session_name}
done: Processing complete{latency_ms, tool_calls_made, message_id, retriever_summary, data_accessed_via_retriever}
error: Error occurred{message, recoverable}
Retriever Events (IMPORTANT - Primary Data Pathway):
retriever_execution: Retriever was used for data access{tool_name, execution_id, retriever_id, is_adhoc, documents_returned, latency_ms, message}- Emitted whenever data is accessed via retriever (saved or ad-hoc)
pipeline_config: Ad-hoc retriever configuration{tool_name, config, message}- Contains the exact pipeline config users can save as a named retriever
Retriever Summary in done Event:
{
"retriever_summary": {
"used_retrievers": true,
"retriever_count": 2,
"saved_retrievers": 1,
"adhoc_retrievers": 1,
"total_documents": 25,
"executions": [...]
},
"data_accessed_via_retriever": true
}
Args: request: FastAPI request with tenant context session_id: Session identifier payload: Message request
Returns: StreamingResponse with SSE events
Raises: NotFoundError: If session not found
Example:
curl -N -X POST http://localhost:8000/v1/agents/sessions/ses_abc123/messages \
-H "Authorization: Bearer {api_key}" \
-H "X-Namespace: {namespace_id}" \
-H "Content-Type: application/json" \
-d '{
"content": "Find videos about machine learning",
"stream": true
}'
# SSE Output:
event: intent
data: {"intent": "retriever_search", "confidence": 0.92, "category": "retriever"}
event: thinking
data: {"step": "processing", "message": "Analyzing your request..."}
event: tool_call
data: {"tool_name": "execute_retriever", "tool_call_id": "run_abc", "inputs": {...}}
event: tool_result
data: {"tool_name": "execute_retriever", "success": true, "output": {...}}
event: retriever_execution
data: {"tool_name": "execute_retriever", "is_adhoc": false, "documents_returned": 5}
event: message
data: {"content": "I found 5 videos about machine learning...", "is_final": true}
event: done
data: {"latency_ms": 1250.5, "data_accessed_via_retriever": true, "retriever_summary": {...}}
curl --request POST \
--url https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Namespace: <api-key>' \
--data '
{
"content": "Find videos about machine learning",
"metadata": {
"source": "web_app"
},
"stream": true
}
'import requests
url = "https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages"
payload = {
"content": "Find videos about machine learning",
"metadata": { "source": "web_app" },
"stream": True
}
headers = {
"Authorization": "Bearer <token>",
"X-Namespace": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'X-Namespace': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: 'Find videos about machine learning',
metadata: {source: 'web_app'},
stream: true
})
};
fetch('https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'content' => 'Find videos about machine learning',
'metadata' => [
'source' => 'web_app'
],
'stream' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Namespace: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages"
payload := strings.NewReader("{\n \"content\": \"Find videos about machine learning\",\n \"metadata\": {\n \"source\": \"web_app\"\n },\n \"stream\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Namespace", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages")
.header("Authorization", "Bearer <token>")
.header("X-Namespace", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"Find videos about machine learning\",\n \"metadata\": {\n \"source\": \"web_app\"\n },\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixpeek.com/v1/agents/sessions/{session_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Namespace"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"Find videos about machine learning\",\n \"metadata\": {\n \"source\": \"web_app\"\n },\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}Authorizations
Mixpeek API key, sent as Authorization: Bearer mxp_sk_.... Create one in Studio under Settings → API Keys, or with an admin key via POST /v1/organizations/users/{user_email}/api-keys. A missing header returns 403; an invalid or revoked key returns 401.
Namespace id (ns_...), not the namespace name. This scopes the request rather than authenticating it, and it is required on every operation marked x-mixpeek-namespace-scoped.
Path Parameters
Session ID
Body
Request payload for sending a message to the agent.
Attributes: content: Message text content metadata: Optional message metadata stream: Whether to stream response as SSE (default: True)
Note: When stream=True, the response will be Server-Sent Events (SSE). When stream=False, the response will be a MessageResponse object.
Example: ```python # Streaming request (SSE) request = SendMessageRequest( content="Find videos about machine learning", stream=True )
# Non-streaming request
request = SendMessageRequest(
content="Find videos about machine learning",
stream=False
)
```
Response
Successful Response
Was this page helpful?

