Read a file or list a directory
Without list: downloads the file at path as raw bytes (application/octet-stream), following a symlink. Its length is declared in Content-Length before the content: a response shorter than its Content-Length was cut (the sandbox stopped answering, the file shrank while it was read, or the time budget ran out); retry. A file over 64 MiB is file_too_large, sent before any content. A directory is path_type_mismatch (list it with list=true), and so is anything that’s neither a file nor a directory (a device, FIFO or socket). Files of at most 1 MiB, pseudo-files included (/proc, /sys), are read whole inside the sandbox first, so their real length is declared; reading a pseudo-file can use up to 64 MiB of the sandbox’s own memory.
With list=true: lists the directory at path (a symlink there is followed) as JSON, sorted by name in byte order and paged with page[number] and page[size]. . and .. aren’t listed; hidden entries are. Symlinks inside are listed as symlink, with their own size and time, never followed; devices, FIFOs and sockets are other. A directory with more than 100000 entries is directory_too_large. Each page is a fresh listing, so entries can move between pages while the directory changes. Names that aren’t valid UTF-8 are shown with each invalid byte replaced by U+FFFD, so they can’t be addressed through these endpoints (use an exec). Listing a file is path_type_mismatch.
path is absolute, at most 4096 bytes in UTF-8, and must be valid UTF-8 once percent-decoded; it’s taken as the sandbox’s kernel resolves it (., .. and // included). A path holding a NUL byte is invalid_path.
The sandbox must be running (else sandbox_not_running); file calls keep working during the stop’s grace period, so you can fetch results from a sandbox that’s ending. They run as the sandbox’s own user, with its permissions: what that user may not do, or a read-only file system, is permission_denied. Another refusal by the sandbox’s file system (no space, a name too long, a busy file or mount point, a symlink loop, an I/O error) is file_operation_failed, with a fixed text naming the reason. File calls don’t count as activity for idle_timeout.
Each call has a 64 MiB limit and a time budget of about 12 s for its whole transfer, so a full-size file needs about 5.3 MiB/s between you and the API to read, and about 6.4 MiB/s to write (a write’s body must arrive 2 s before the budget ends). Move larger data through Cloud Storage from an exec.
curl --request GET \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/files \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/files"
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}/files', 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}/files",
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}/files"
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}/files")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/files")
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": [
{
"name": "results.json",
"path": "/app/out/results.json",
"type": "file",
"size_bytes": 18234,
"modified_at": "2026-11-13T10:42:17Z"
},
{
"name": "checkpoints",
"path": "/app/out/checkpoints",
"type": "directory",
"size_bytes": 4096,
"modified_at": "2026-11-13T10:40:02Z"
}
],
"meta": {
"page_number": 1,
"page_size": 20,
"total_pages": 1,
"total_results": 2
}
}{
"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": "path_type_mismatch",
"detail": "The path is a directory."
}
]
}{
"errors": [
{
"title": "file_too_large",
"detail": "The file is larger than 64 MiB."
}
]
}{
"errors": [
{
"title": "invalid_path",
"detail": "The path is reserved."
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}Authorizations
Query Parameters
Response
The file's bytes (application/octet-stream, with Content-Length; a shorter body was cut), or with list=true the directory listing (application/json).
Was this page helpful?
curl --request GET \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/files \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/files"
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}/files', 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}/files",
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}/files"
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}/files")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/files")
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": [
{
"name": "results.json",
"path": "/app/out/results.json",
"type": "file",
"size_bytes": 18234,
"modified_at": "2026-11-13T10:42:17Z"
},
{
"name": "checkpoints",
"path": "/app/out/checkpoints",
"type": "directory",
"size_bytes": 4096,
"modified_at": "2026-11-13T10:40:02Z"
}
],
"meta": {
"page_number": 1,
"page_size": 20,
"total_pages": 1,
"total_results": 2
}
}{
"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": "path_type_mismatch",
"detail": "The path is a directory."
}
]
}{
"errors": [
{
"title": "file_too_large",
"detail": "The file is larger than 64 MiB."
}
]
}{
"errors": [
{
"title": "invalid_path",
"detail": "The path is reserved."
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}