curl --request POST \
--url https://api.example.com/threads/stream_query \
--header 'Content-Type: application/json' \
--data '
{
"project_id": "my_entity/my_project",
"filter": {
"after_datetime": "2024-01-01T00:00:00Z",
"before_datetime": "2024-12-31T23:59:59Z",
"thread_ids": [
"thread_1",
"thread_2",
"my_thread_id"
]
},
"limit": 123,
"offset": 123,
"sort_by": [
{
"direction": "desc",
"field": "last_updated"
}
]
}
'import requests
url = "https://api.example.com/threads/stream_query"
payload = {
"project_id": "my_entity/my_project",
"filter": {
"after_datetime": "2024-01-01T00:00:00Z",
"before_datetime": "2024-12-31T23:59:59Z",
"thread_ids": ["thread_1", "thread_2", "my_thread_id"]
},
"limit": 123,
"offset": 123,
"sort_by": [
{
"direction": "desc",
"field": "last_updated"
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
project_id: 'my_entity/my_project',
filter: {
after_datetime: '2024-01-01T00:00:00Z',
before_datetime: '2024-12-31T23:59:59Z',
thread_ids: ['thread_1', 'thread_2', 'my_thread_id']
},
limit: 123,
offset: 123,
sort_by: [{direction: 'desc', field: 'last_updated'}]
})
};
fetch('https://api.example.com/threads/stream_query', 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.example.com/threads/stream_query",
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([
'project_id' => 'my_entity/my_project',
'filter' => [
'after_datetime' => '2024-01-01T00:00:00Z',
'before_datetime' => '2024-12-31T23:59:59Z',
'thread_ids' => [
'thread_1',
'thread_2',
'my_thread_id'
]
],
'limit' => 123,
'offset' => 123,
'sort_by' => [
[
'direction' => 'desc',
'field' => 'last_updated'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/threads/stream_query"
payload := strings.NewReader("{\n \"project_id\": \"my_entity/my_project\",\n \"filter\": {\n \"after_datetime\": \"2024-01-01T00:00:00Z\",\n \"before_datetime\": \"2024-12-31T23:59:59Z\",\n \"thread_ids\": [\n \"thread_1\",\n \"thread_2\",\n \"my_thread_id\"\n ]\n },\n \"limit\": 123,\n \"offset\": 123,\n \"sort_by\": [\n {\n \"direction\": \"desc\",\n \"field\": \"last_updated\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/threads/stream_query")
.header("Content-Type", "application/json")
.body("{\n \"project_id\": \"my_entity/my_project\",\n \"filter\": {\n \"after_datetime\": \"2024-01-01T00:00:00Z\",\n \"before_datetime\": \"2024-12-31T23:59:59Z\",\n \"thread_ids\": [\n \"thread_1\",\n \"thread_2\",\n \"my_thread_id\"\n ]\n },\n \"limit\": 123,\n \"offset\": 123,\n \"sort_by\": [\n {\n \"direction\": \"desc\",\n \"field\": \"last_updated\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/threads/stream_query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"project_id\": \"my_entity/my_project\",\n \"filter\": {\n \"after_datetime\": \"2024-01-01T00:00:00Z\",\n \"before_datetime\": \"2024-12-31T23:59:59Z\",\n \"thread_ids\": [\n \"thread_1\",\n \"thread_2\",\n \"my_thread_id\"\n ]\n },\n \"limit\": 123,\n \"offset\": 123,\n \"sort_by\": [\n {\n \"direction\": \"desc\",\n \"field\": \"last_updated\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"thread_id": "<string>",
"turn_count": 123,
"start_time": "2023-11-07T05:31:56Z",
"last_updated": "2023-11-07T05:31:56Z",
"first_turn_id": "<string>",
"last_turn_id": "<string>",
"p50_turn_duration_ms": 123,
"p99_turn_duration_ms": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Threads Query Stream
curl --request POST \
--url https://api.example.com/threads/stream_query \
--header 'Content-Type: application/json' \
--data '
{
"project_id": "my_entity/my_project",
"filter": {
"after_datetime": "2024-01-01T00:00:00Z",
"before_datetime": "2024-12-31T23:59:59Z",
"thread_ids": [
"thread_1",
"thread_2",
"my_thread_id"
]
},
"limit": 123,
"offset": 123,
"sort_by": [
{
"direction": "desc",
"field": "last_updated"
}
]
}
'import requests
url = "https://api.example.com/threads/stream_query"
payload = {
"project_id": "my_entity/my_project",
"filter": {
"after_datetime": "2024-01-01T00:00:00Z",
"before_datetime": "2024-12-31T23:59:59Z",
"thread_ids": ["thread_1", "thread_2", "my_thread_id"]
},
"limit": 123,
"offset": 123,
"sort_by": [
{
"direction": "desc",
"field": "last_updated"
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
project_id: 'my_entity/my_project',
filter: {
after_datetime: '2024-01-01T00:00:00Z',
before_datetime: '2024-12-31T23:59:59Z',
thread_ids: ['thread_1', 'thread_2', 'my_thread_id']
},
limit: 123,
offset: 123,
sort_by: [{direction: 'desc', field: 'last_updated'}]
})
};
fetch('https://api.example.com/threads/stream_query', 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.example.com/threads/stream_query",
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([
'project_id' => 'my_entity/my_project',
'filter' => [
'after_datetime' => '2024-01-01T00:00:00Z',
'before_datetime' => '2024-12-31T23:59:59Z',
'thread_ids' => [
'thread_1',
'thread_2',
'my_thread_id'
]
],
'limit' => 123,
'offset' => 123,
'sort_by' => [
[
'direction' => 'desc',
'field' => 'last_updated'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/threads/stream_query"
payload := strings.NewReader("{\n \"project_id\": \"my_entity/my_project\",\n \"filter\": {\n \"after_datetime\": \"2024-01-01T00:00:00Z\",\n \"before_datetime\": \"2024-12-31T23:59:59Z\",\n \"thread_ids\": [\n \"thread_1\",\n \"thread_2\",\n \"my_thread_id\"\n ]\n },\n \"limit\": 123,\n \"offset\": 123,\n \"sort_by\": [\n {\n \"direction\": \"desc\",\n \"field\": \"last_updated\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/threads/stream_query")
.header("Content-Type", "application/json")
.body("{\n \"project_id\": \"my_entity/my_project\",\n \"filter\": {\n \"after_datetime\": \"2024-01-01T00:00:00Z\",\n \"before_datetime\": \"2024-12-31T23:59:59Z\",\n \"thread_ids\": [\n \"thread_1\",\n \"thread_2\",\n \"my_thread_id\"\n ]\n },\n \"limit\": 123,\n \"offset\": 123,\n \"sort_by\": [\n {\n \"direction\": \"desc\",\n \"field\": \"last_updated\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/threads/stream_query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"project_id\": \"my_entity/my_project\",\n \"filter\": {\n \"after_datetime\": \"2024-01-01T00:00:00Z\",\n \"before_datetime\": \"2024-12-31T23:59:59Z\",\n \"thread_ids\": [\n \"thread_1\",\n \"thread_2\",\n \"my_thread_id\"\n ]\n },\n \"limit\": 123,\n \"offset\": 123,\n \"sort_by\": [\n {\n \"direction\": \"desc\",\n \"field\": \"last_updated\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"thread_id": "<string>",
"turn_count": 123,
"start_time": "2023-11-07T05:31:56Z",
"last_updated": "2023-11-07T05:31:56Z",
"first_turn_id": "<string>",
"last_turn_id": "<string>",
"p50_turn_duration_ms": 123,
"p99_turn_duration_ms": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Body
Query threads with aggregated statistics based on turn calls only.
Turn calls are the immediate children of thread contexts (where call.id == turn_id). This provides meaningful conversation-level statistics rather than including all nested implementation details.
The ID of the project
"my_entity/my_project"
Filter criteria for the threads query
Show child attributes
Show child attributes
Maximum number of threads to return
Number of threads to skip
Sorting criteria for the threads. Supported fields: 'thread_id', 'turn_count', 'start_time', 'last_updated', 'p50_turn_duration_ms', 'p99_turn_duration_ms'.
Show child attributes
Show child attributes
[
{
"direction": "desc",
"field": "last_updated"
}
]
Response
Stream of data in JSONL format
Number of turn calls in this thread
Earliest start time of turn calls in this thread
Latest end time of turn calls in this thread
Turn ID of the first turn in this thread (earliest start_time)
Turn ID of the latest turn in this thread (latest end_time)
50th percentile (median) of turn durations in milliseconds within this thread
99th percentile of turn durations in milliseconds within this thread
Was this page helpful?