Overview
Threads provide a way to:- Group related requests together
- Track conversation history
- Filter traces by conversation
- Analyze user journeys and agent workflows
List threads
Retrieve all threads with optional filtering.Endpoint
Parameters
Maximum number of threads to return
Number of threads to skip for pagination
Filter threads by project ID
Response
Array of thread objects
Example
cURL
Python
Get thread details
Retrieve detailed information about a specific thread.Endpoint
Path Parameters
Thread ID
Response
Thread identifier
Thread creation timestamp
Last update timestamp
Custom metadata
Array of run objects in this thread
Example
cURL
Update thread
Update thread metadata or properties.Endpoint
Path Parameters
Thread ID to update
Request Body
Custom metadata to attach to the thread
Example
cURL
Using threads in requests
Assign requests to threads using theX-Thread-ID header:
Filtering traces by thread
Use thread IDs to filter traces:Best practices
Use meaningful thread IDs
Use meaningful thread IDs
Choose descriptive thread IDs that help identify conversations:
user-123-supportfor support conversationssession-abc-onboardingfor onboarding flowsagent-xyz-task-456for agent workflows
Add metadata early
Add metadata early
Attach relevant metadata to threads as soon as they’re created. This makes filtering and analysis easier later.
Thread lifecycle
Thread lifecycle
Threads are created automatically when you first use a thread ID in a request. You don’t need to explicitly create them.
Cleanup old threads
Cleanup old threads
Regularly archive or delete old threads to keep your database manageable. There’s no automatic cleanup.
Next steps
Traces API
Query traces within threads
Runs API
View run details in threads
Real-time Tracing
Monitor thread activity in real-time
Projects
Organize threads by project