Threads Query Stream
curl --request POST \
--url https://api.example.com/threads/stream_query \
--header 'Content-Type: application/json' \
--data '
{
"project_id": "<string>",
"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": "<string>",
"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: '<string>',
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' => '<string>',
'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\": \"<string>\",\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\": \"<string>\",\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\": \"<string>\",\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{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Threads Query Stream
POST
/
threads
/
stream_query
Threads Query Stream
curl --request POST \
--url https://api.example.com/threads/stream_query \
--header 'Content-Type: application/json' \
--data '
{
"project_id": "<string>",
"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": "<string>",
"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: '<string>',
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' => '<string>',
'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\": \"<string>\",\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\": \"<string>\",\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\": \"<string>\",\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{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
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
Example:
"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
Example:
[
{
"direction": "desc",
"field": "last_updated"
}
]Response
Successful Response
Was this page helpful?
⌘I