Traces API
Traces represent conversation contexts for multi-turn interactions and execution tracking. They automatically track message history, state, and provide a unified interface for managing conversation flows.Overview
Traces are the primary mechanism for:- Conversation Context: Multi-turn interactions with AI agents
- Execution Tracking: Following the execution flow of receptors, neurons, and pathways
- Message History: Storing and retrieving conversation messages
- State Management: Maintaining context across multiple interactions
List Traces
List traces with filtering and pagination.Query Parameters
| Parameter | Type | Description |
|---|---|---|
brain_id | string | Filter by brain ID |
receptor_id | string | Filter by receptor ID (alias: synapse_id) |
user_id | string | Filter by user ID |
search | string | Search in trace_id and metadata.title |
created_after | string | ISO date; filter traces created after |
created_before | string | ISO date; filter traces created before |
limit | number | Max traces to return (default: 20) |
offset | number | Pagination offset |
sort | string | Sort field: created_at, updated_at, message_count |
order | string | Sort order: asc or desc |
Example Request
- TypeScript
- curl
Example Response
synapse_id for compatibility; engrams store receptor_id. Use receptor_id when filtering.
Get Trace
Get a single trace by ID.Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Trace ID |
Example Request
- TypeScript
- curl
Example Response
Get Trace Messages
Get message history for a trace with pagination support.Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Trace ID |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit | number | Maximum number of messages to return (default: unlimited) |
cursor | string | Cursor for pagination (optional) |
Example Request
- TypeScript
- curl
Example Response
Message Roles
Messages support the following roles:user- User messagesassistant- AI assistant responsessystem- System messagesneuron- Messages from neuron executions
Add Message to Trace
Add a message to a trace. This will automatically create the trace if it doesn’t exist.Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Trace ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | Message role: user, assistant, system, or neuron |
content | string | Yes | Message content |
metadata | object | No | Additional metadata (e.g., content_blocks, tool call info) |
memory_ids | array | No | Array of memory UUIDs to link to the trace |
Example Request
- TypeScript
- curl
Example Response
Public Trace Access
Traces can be accessed via share tokens for public access without requiring full authentication.Get Public Trace
Get a trace using a share token.Path Parameters
| Parameter | Type | Description |
|---|---|---|
trace_id | string | Trace ID |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
t | string | Share token (required) |
workspace | string | Workspace slug (required) |
receptor | string | Receptor slug (required) |
Example Request
- TypeScript
- curl
Get Public Trace Messages
Get messages for a trace using a share token. This endpoint uses/v1/traces/:trace_id/messages with share token authentication via query parameters.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
trace_id | string | Trace ID |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
t | string | Share token (required) |
workspace | string | Workspace slug (required) |
receptor | string | Receptor slug (required) |
limit | number | Maximum number of messages (optional) |
Example Request
- TypeScript
- curl
Trace Lifecycle
Traces follow a simple lifecycle:- Creation: Traces are automatically created when the first message is added
- Messages: Messages are added sequentially to build conversation history
- State: Trace state is maintained automatically through engrams
- Retrieval: Traces and their messages can be retrieved at any time
Integration with Receptors
Traces are created and managed when you invoke receptors with atrace_id:
Memory Linking
Traces can be linked to memories for RAG (Retrieval-Augmented Generation):Error Handling
Common error scenarios:- 404 Not Found: Trace doesn’t exist
- 403 Forbidden: Insufficient permissions to access trace
- 400 Bad Request: Invalid trace ID format or missing required fields
Related
- Memories API - Store persistent memories for traces
- Recollections API - Manage trace recollections
- Integration patterns - Stream receptor execution responses
- Activity API - View trace activity and engrams