Skip to main content
POST
/
threads
/
{thread_id}
/
stream
/
events
Protocol v2 Event Stream (SSE)
curl --request POST \
  --url https://api.example.com/threads/{thread_id}/stream/events \
  --header 'Content-Type: application/json' \
  --data '
{
  "channels": [],
  "namespaces": [
    [
      "<string>"
    ]
  ],
  "depth": 1,
  "since": 1
}
'
import requests

url = "https://api.example.com/threads/{thread_id}/stream/events"

payload = {
    "channels": [],
    "namespaces": [["<string>"]],
    "depth": 1,
    "since": 1
}
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({channels: [], namespaces: [['<string>']], depth: 1, since: 1})
};

fetch('https://api.example.com/threads/{thread_id}/stream/events', 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/{thread_id}/stream/events",
  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([
    'channels' => [
        
    ],
    'namespaces' => [
        [
                '<string>'
        ]
    ],
    'depth' => 1,
    'since' => 1
  ]),
  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/{thread_id}/stream/events"

	payload := strings.NewReader("{\n  \"channels\": [],\n  \"namespaces\": [\n    [\n      \"<string>\"\n    ]\n  ],\n  \"depth\": 1,\n  \"since\": 1\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/{thread_id}/stream/events")
  .header("Content-Type", "application/json")
  .body("{\n  \"channels\": [],\n  \"namespaces\": [\n    [\n      \"<string>\"\n    ]\n  ],\n  \"depth\": 1,\n  \"since\": 1\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/threads/{thread_id}/stream/events")

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  \"channels\": [],\n  \"namespaces\": [\n    [\n      \"<string>\"\n    ]\n  ],\n  \"depth\": 1,\n  \"since\": 1\n}"

response = http.request(request)
puts response.read_body
"<string>"
{
  "detail": "<string>"
}

Path Parameters

thread_id
string<uuid>
required

The ID of the thread to observe.

Body

application/json

Body of POST /threads/{thread_id}/stream/events. Filters the connection-scoped SSE stream.

channels
(enum<string> | string)[]
required

Channels to subscribe to for the lifetime of this connection.

Minimum array length: 1

Subscribable event channel. One of the eight fixed channels or a user-defined custom:<name> namespaced custom channel emitted by a stream transformer. debug and checkpoints were removed from the protocol in @langchain/protocol@0.0.10 — task-level debug info now flows on the tasks channel, and checkpoint pointers ride on values events as an attached checkpoint envelope.

Available options:
values,
updates,
messages,
tools,
lifecycle,
input,
tasks,
custom
namespaces
string[][]

Prefix-match filter. An event matches if its namespace starts with any of these prefixes. Omit for all namespaces.

Hierarchical path identifying a position in the agent tree. Empty array denotes the root agent; each segment names a nested subgraph.

depth
integer

Max depth below the namespace prefix. Omit for unbounded depth.

Required range: x >= 0
since
integer

Replay events with seq greater than this value before streaming live events.

Required range: x >= 0

Response

SSE event stream

Stream of ProtocolEvent frames. Each SSE frame uses the event's method as the event: field and a JSON-encoded ProtocolEvent as the data: field; id: is set to the event's seq.

Example frame:

id: 42

event: messages

data: {"type":"event","event_id":"42","seq":42,"method":"messages","params":{"namespace":[],"timestamp":1700000000000,"data":{...}}}