Terminate a sandbox
Stops the sandbox. A queued or preparing sandbox is cancelled at once. A sandbox that has been placed is stopped asynchronously: its processes get SIGTERM, then SIGKILL if they’re still running after a grace period, and it reaches terminated with termination_reason: terminated_by_user and the main process’s exit_code if it ran. The response shows the sandbox as it is now; use GET /ai/sandboxes/{sandbox_id}/wait to see it end.
If the sandbox already ended on its own, its own reason stays. Terminating a terminated sandbox succeeds and changes nothing.
curl --request POST \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate', 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}/terminate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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}/terminate"
req, _ := http.NewRequest("POST", 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.post("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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": "running",
"ready": true,
"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": null,
"termination_message": null,
"exit_code": null,
"created_at": "2026-11-13T10:00:00Z",
"started_at": "2026-11-13T10:01:12Z",
"terminated_at": null
}
}{
"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": "request_in_progress",
"detail": "A request with this Idempotency-Key is still being processed."
}
]
}{
"errors": [
{
"title": "idempotency_key_reused",
"detail": "This Idempotency-Key was used with a different request."
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}Authorizations
Headers
Optional client-chosen key (e.g. a UUID, at most 255 characters) that makes the call safe to retry. Within 24 h, the same key with the same request returns the stored response instead of acting twice; the same key with a different request fails with idempotency_key_reused; a request with a key that's still being processed fails with request_in_progress.
1 - 255Was this page helpful?
curl --request POST \
--url https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate', 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}/terminate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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}/terminate"
req, _ := http.NewRequest("POST", 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.post("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/terminate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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": "running",
"ready": true,
"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": null,
"termination_message": null,
"exit_code": null,
"created_at": "2026-11-13T10:00:00Z",
"started_at": "2026-11-13T10:01:12Z",
"terminated_at": null
}
}{
"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": "request_in_progress",
"detail": "A request with this Idempotency-Key is still being processed."
}
]
}{
"errors": [
{
"title": "idempotency_key_reused",
"detail": "This Idempotency-Key was used with a different request."
}
]
}{
"errors": [
{
"code": "10037",
"title": "Service unavailable",
"detail": "A dependency can't answer right now; retry later."
}
]
}