Query Threads
Changed onGET with body payload — no resources created. Returns the threads in a tracing project matching the query passed as the request payload. Results are filtered by the given time range and optional filters, with cursor-based pagination.
When ai_search is set, Accept: text/event-stream is required; requests without it return 406. AI search is unavailable on deployments that route queries to the v1 backend and returns 501 there.
Self-hosted deployments require LangSmith v0.16 or later.
Request
- Base URLhttps://api.smith.langchain.com
- URLhttps://api.smith.langchain.com/api/v2/threads/query
- Auth
- API key in header X-API-Key and API key in header X-Tenant-Id
- or HTTP bearer and API key in header X-Tenant-Id
Headers
application/json, or text/event-stream (required when ai_search is set)
Request body
Example request
{
"ai_search": "A conversation about a refund request",
"page_size": 20,
"project_id": "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328",
"thread_filter": "gte(turn_count, 3)",
"trace_filter": "eq(status, \"error\")",
"tree_filter": "has(tags, \"production\")"
}Response
items and pagination
Example response
{
"items": [
{
"count": 3,
"first_trace_id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
"last_trace_id": "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328",
"latency_p50": 0.15,
"latency_p99": 0.42,
"max_start_time": "2025-01-15T12:05:00.000Z",
"min_start_time": "2025-01-15T12:00:00.000Z",
"num_errored_turns": 1,
"start_time": "2025-01-15T12:00:00.000Z",
"thread_id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327",
"total_cost": 0.045,
"total_tokens": 450,
"trace_id": "018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9328"
}
],
"next_cursor": "eyJydW5zX2N1cnNvciI6Imx0KGN1cnNvciwiLi4uIikifQ=="
}Changes
- info
removed the non-success response with the status
- info
removed the non-success response with the status
- info
removed the non-success response with the status
- info
removed the non-success response with the status
- info
removed the non-success response with the status
- info
- info
endpoint added
- info