Read or follow a sandbox's logs
The output (stdout and stderr) of the sandbox’s main process. Exec output isn’t included; read it through the exec attach WebSocket.
follow=false(default): one page of stored output as JSON, in order. Paging uses a cursor, not page numbers, because the log keeps growing: passmeta.next_page_afteraspage[after]for the next page.meta.next_page_afterisnullonce you’ve reached the end of what’s stored so far; keep your last position to poll a running sandbox.follow=true: a Server-Sent Events stream (text/event-stream): the output stored so far, then new output a few seconds after the sandbox prints it. Everylogandgapevent’sidis a position: after a cut connection (e.g. the edge proxy’s ~600 s connection limit), reconnect withLast-Event-ID(orpage[after]) to continue without gaps or duplicates. A heartbeat comment arrives every 30 s. Once the sandbox has ended and every stored line was sent, anendevent says how its log ended:complete,incomplete(withreason), orsettling(a later read may return more); then the stream closes. A sandbox that hasn’t ended, queued ones included, never getsend.
Every line names its stream, and stream=stdout|stderr keeps only that stream’s lines (and the gaps that touch it), with either value of follow. Lines are in the order they were stored, which closely follows the order the sandbox printed them (lines a few seconds apart can interleave); each carries the time it was written, to the nanosecond. Lines are cut at 256 KiB, and bytes that weren’t valid UTF-8 appear as U+FFFD.
Output that isn’t available is shown in place as a gap entry, never skipped, with its reason: expired (past its retention, or removed or changed in your bucket), log_bucket_unavailable (your bucket couldn’t be written) or size_cap_reached. A position that isn’t one this API returned is a 422.
The logs are stored in your own Cloud Storage bucket (the sandbox’s log_bucket), where you can also read them with any S3 tool: under sandboxes/{sandbox_id}/, zstd-compressed NDJSON objects, one record per line, {"ts": …, "stream": "stdout"|"stderr", "line": …}: chunk objects (chunks/<sha256>.ndjson.zst) while the sandbox runs, then the whole log as logs-<id>-<nnnn>.ndjson.zst.
curl --request GET \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs', 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.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"type": "line",
"position": "p1.12.0",
"ts": "2026-11-13T10:01:15.123456789Z",
"stream": "stdout",
"line": "epoch 1/3: loss=2.314"
},
{
"type": "gap",
"position": "p1.12.1",
"reason": "size_cap_reached",
"stream": null,
"records": null,
"from_ts": "2026-11-13T10:01:16Z",
"to_ts": null
}
],
"meta": {
"next_page_after": "p1.12.1",
"page_size": 20
}
}{
"errors": [
{
"title": "<string>",
"code": "<string>",
"detail": "<string>",
"meta": {
"url": null
},
"source": {
"parameter": null,
"pointer": null
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "Could not find any usable credentials in the request."
}
]
}{
"errors": [
{
"title": "sandboxes_not_whitelisted",
"detail": "The organization isn't whitelisted."
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "Sandbox not found."
}
]
}{
"errors": [
{
"title": "<string>",
"code": "<string>",
"detail": "<string>",
"meta": {
"url": null
},
"source": {
"parameter": null,
"pointer": null
}
}
]
}{
"errors": [
{
"title": "too_many_log_readers",
"detail": "Too many log streams are open for this organization."
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}Authorizations
Headers
Query Parameters
Response
follow=false: a JSON page (application/json). follow=true: a Server-Sent Events stream (text/event-stream) of log, gap and end events, whose data are the JSON objects LogLine, LogGap and LogEnd.
A page of stored output, in order. Paged by cursor: pass
meta.next_page_after as page[after] for the next page.
Was this page helpful?
curl --request GET \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs', 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.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"type": "line",
"position": "p1.12.0",
"ts": "2026-11-13T10:01:15.123456789Z",
"stream": "stdout",
"line": "epoch 1/3: loss=2.314"
},
{
"type": "gap",
"position": "p1.12.1",
"reason": "size_cap_reached",
"stream": null,
"records": null,
"from_ts": "2026-11-13T10:01:16Z",
"to_ts": null
}
],
"meta": {
"next_page_after": "p1.12.1",
"page_size": 20
}
}{
"errors": [
{
"title": "<string>",
"code": "<string>",
"detail": "<string>",
"meta": {
"url": null
},
"source": {
"parameter": null,
"pointer": null
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "Could not find any usable credentials in the request."
}
]
}{
"errors": [
{
"title": "sandboxes_not_whitelisted",
"detail": "The organization isn't whitelisted."
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "Sandbox not found."
}
]
}{
"errors": [
{
"title": "<string>",
"code": "<string>",
"detail": "<string>",
"meta": {
"url": null
},
"source": {
"parameter": null,
"pointer": null
}
}
]
}{
"errors": [
{
"title": "too_many_log_readers",
"detail": "Too many log streams are open for this organization."
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}