Wait for a sandbox to end
Long-poll: returns as soon as the sandbox is terminated, or after at most 10 s, whichever comes first, always with 200 and the sandbox as it is then. If state isn’t terminated yet, call again. This is how you wait for a long-running sandbox without holding one connection open.
GET
/
ai
/
sandboxes
/
{sandbox_id}
/
wait
Wait for a sandbox to end
curl --request GET \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/wait \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/wait"
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}/wait', 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}/wait",
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}/wait"
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}/wait")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/wait")
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": {
"id": "sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e",
"name": "train-run-42",
"tags": {
"project": "llm-ft"
},
"state": "terminated",
"ready": false,
"image": {
"ref": "ghcr.io/acme/trainer:1.4"
},
"command": [
"python",
"train.py"
],
"workdir": "/app",
"env": {
"EPOCHS": "3"
},
"gpu": {
"type": "B300",
"count": 8
},
"cpu": 192,
"memory_mib": 2097152,
"disk_gib": 8192,
"timeout": 36000,
"idle_timeout": null,
"queue_timeout": 1800,
"network_mode": "public",
"cidr_allowlist": null,
"readiness_probe": null,
"log_bucket": "acme-sandbox-logs",
"logs_incomplete": false,
"logs_incomplete_reason": null,
"resolved": {
"image": "ghcr.io/acme/trainer@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"command": [
"python",
"train.py"
],
"workdir": "/app"
},
"termination_reason": "terminated_by_user",
"termination_message": null,
"exit_code": 143,
"created_at": "2026-11-13T10:00:00Z",
"started_at": "2026-11-13T10:01:12Z",
"terminated_at": "2026-11-13T12:30:05Z"
}
}{
"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": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}Authorizations
Query Parameters
Was this page helpful?
Wait for a sandbox to end
curl --request GET \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/wait \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/wait"
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}/wait', 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}/wait",
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}/wait"
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}/wait")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/wait")
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": {
"id": "sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e",
"name": "train-run-42",
"tags": {
"project": "llm-ft"
},
"state": "terminated",
"ready": false,
"image": {
"ref": "ghcr.io/acme/trainer:1.4"
},
"command": [
"python",
"train.py"
],
"workdir": "/app",
"env": {
"EPOCHS": "3"
},
"gpu": {
"type": "B300",
"count": 8
},
"cpu": 192,
"memory_mib": 2097152,
"disk_gib": 8192,
"timeout": 36000,
"idle_timeout": null,
"queue_timeout": 1800,
"network_mode": "public",
"cidr_allowlist": null,
"readiness_probe": null,
"log_bucket": "acme-sandbox-logs",
"logs_incomplete": false,
"logs_incomplete_reason": null,
"resolved": {
"image": "ghcr.io/acme/trainer@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"command": [
"python",
"train.py"
],
"workdir": "/app"
},
"termination_reason": "terminated_by_user",
"termination_message": null,
"exit_code": 143,
"created_at": "2026-11-13T10:00:00Z",
"started_at": "2026-11-13T10:01:12Z",
"terminated_at": "2026-11-13T12:30:05Z"
}
}{
"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": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}