Create a sandbox
Creates a sandbox and returns it at once in state queued. It then starts in the background (queued → preparing, when its GPUs need preparing → scheduled → starting → running); follow it with GET /ai/sandboxes/{sandbox_id}, or wait for it to end with GET /ai/sandboxes/{sandbox_id}/wait.
Set gpu to a type and a count from its allowed_counts, as listed by GET /ai/sandbox-gpu-types. Currently each type lists one count, its node’s GPU count, so a sandbox rents a whole GPU node. Its CPU, memory and disk come from the type.
Defaults: timeout 300 s (send null for no limit), queue_timeout 600 s, network mode public.
When there’s no capacity, the sandbox waits in the queue for up to queue_timeout; queued and preparing time isn’t billed. A create that would take your organization over its GPU limit for the type fails at once with quota_exceeded; contact support to raise the limit.
Send an Idempotency-Key: if the response is lost, a retry with the same key returns the same sandbox instead of starting (and billing) a second one.
curl --request POST \
--url https://api.telnyx.com/v2/ai/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "train-run-42",
"tags": {
"project": "llm-ft"
},
"image": {
"ref": "ghcr.io/acme/trainer:1.4"
},
"command": [
"python",
"train.py"
],
"workdir": "/app",
"env": {
"EPOCHS": "3"
},
"gpu": {
"type": "B300",
"count": 8
},
"timeout": 36000,
"queue_timeout": 1800
}
'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes"
payload = {
"name": "train-run-42",
"tags": { "project": "llm-ft" },
"image": { "ref": "ghcr.io/acme/trainer:1.4" },
"command": ["python", "train.py"],
"workdir": "/app",
"env": { "EPOCHS": "3" },
"gpu": {
"type": "B300",
"count": 8
},
"timeout": 36000,
"queue_timeout": 1800
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'train-run-42',
tags: {project: 'llm-ft'},
image: {ref: 'ghcr.io/acme/trainer:1.4'},
command: ['python', 'train.py'],
workdir: '/app',
env: {EPOCHS: '3'},
gpu: {type: 'B300', count: 8},
timeout: 36000,
queue_timeout: 1800
})
};
fetch('https://api.telnyx.com/v2/ai/sandboxes', 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",
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([
'name' => 'train-run-42',
'tags' => [
'project' => 'llm-ft'
],
'image' => [
'ref' => 'ghcr.io/acme/trainer:1.4'
],
'command' => [
'python',
'train.py'
],
'workdir' => '/app',
'env' => [
'EPOCHS' => '3'
],
'gpu' => [
'type' => 'B300',
'count' => 8
],
'timeout' => 36000,
'queue_timeout' => 1800
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.telnyx.com/v2/ai/sandboxes"
payload := strings.NewReader("{\n \"name\": \"train-run-42\",\n \"tags\": {\n \"project\": \"llm-ft\"\n },\n \"image\": {\n \"ref\": \"ghcr.io/acme/trainer:1.4\"\n },\n \"command\": [\n \"python\",\n \"train.py\"\n ],\n \"workdir\": \"/app\",\n \"env\": {\n \"EPOCHS\": \"3\"\n },\n \"gpu\": {\n \"type\": \"B300\",\n \"count\": 8\n },\n \"timeout\": 36000,\n \"queue_timeout\": 1800\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.telnyx.com/v2/ai/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"train-run-42\",\n \"tags\": {\n \"project\": \"llm-ft\"\n },\n \"image\": {\n \"ref\": \"ghcr.io/acme/trainer:1.4\"\n },\n \"command\": [\n \"python\",\n \"train.py\"\n ],\n \"workdir\": \"/app\",\n \"env\": {\n \"EPOCHS\": \"3\"\n },\n \"gpu\": {\n \"type\": \"B300\",\n \"count\": 8\n },\n \"timeout\": 36000,\n \"queue_timeout\": 1800\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"train-run-42\",\n \"tags\": {\n \"project\": \"llm-ft\"\n },\n \"image\": {\n \"ref\": \"ghcr.io/acme/trainer:1.4\"\n },\n \"command\": [\n \"python\",\n \"train.py\"\n ],\n \"workdir\": \"/app\",\n \"env\": {\n \"EPOCHS\": \"3\"\n },\n \"gpu\": {\n \"type\": \"B300\",\n \"count\": 8\n },\n \"timeout\": 36000,\n \"queue_timeout\": 1800\n}"
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": "queued",
"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": null,
"logs_incomplete": false,
"logs_incomplete_reason": null,
"resolved": null,
"termination_reason": null,
"termination_message": null,
"exit_code": null,
"created_at": "2026-11-13T10:00:00Z",
"started_at": null,
"terminated_at": null
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "Input should be greater than or equal to 1.",
"source": {
"pointer": "/timeout"
}
}
]
}{
"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": [
{
"title": "request_in_progress",
"detail": "A request with this Idempotency-Key is still being processed."
}
]
}{
"errors": [
{
"title": "resources_not_allowed",
"detail": "GPU type `H100` isn't available; see GET /sandbox-gpu-types.",
"source": {
"pointer": "/gpu/type"
}
}
]
}{
"errors": [
{
"title": "quota_exceeded",
"detail": "This sandbox would exceed your organization's GPU limit for B300: limit 8, 8 in use, 8 requested. Contact support to request a higher limit.",
"source": {
"pointer": "/gpu/count"
}
}
]
}{
"errors": [
{
"title": "sandbox_creation_paused",
"detail": "Creating sandboxes is paused; 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 - 255Body
A new sandbox. image and gpu are required.
Allow outbound traffic only to these CIDRs (network mode allowlist). Internal address ranges are always excluded; a CIDR entirely inside them fails with cidr_not_allowed. DNS isn't included: allow your resolver's addresses, or connect by IP. Can't be combined with block_network.
1End the sandbox (reason idle_timeout) after this many seconds of no activity. Activity is an exec running, starting or finishing, and stdin written to an exec or to the main process. Reading output doesn't count, nor do file calls (reading, writing, listing or deleting files), nor does the main process's own work: a sandbox whose main process is a server, with nothing else going on, ends after idle_timeout. Must not exceed timeout when that is a number. Default: none.
x >= 1Your own Cloud Storage bucket for this sandbox's logs. It must exist, belong to your organization, be in the Cloud Storage region this service keeps sandbox logs in, and be writable; otherwise the create fails with log_bucket_not_allowed. Omit it to use a bucket created for you in your account, with a 30-day lifecycle rule; the sandbox waits for that bucket before it waits for capacity.
3 - 63^[a-z0-9][a-z0-9.-]*[a-z0-9]$Was this page helpful?
curl --request POST \
--url https://api.telnyx.com/v2/ai/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "train-run-42",
"tags": {
"project": "llm-ft"
},
"image": {
"ref": "ghcr.io/acme/trainer:1.4"
},
"command": [
"python",
"train.py"
],
"workdir": "/app",
"env": {
"EPOCHS": "3"
},
"gpu": {
"type": "B300",
"count": 8
},
"timeout": 36000,
"queue_timeout": 1800
}
'import requests
url = "https://api.telnyx.com/v2/ai/sandboxes"
payload = {
"name": "train-run-42",
"tags": { "project": "llm-ft" },
"image": { "ref": "ghcr.io/acme/trainer:1.4" },
"command": ["python", "train.py"],
"workdir": "/app",
"env": { "EPOCHS": "3" },
"gpu": {
"type": "B300",
"count": 8
},
"timeout": 36000,
"queue_timeout": 1800
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'train-run-42',
tags: {project: 'llm-ft'},
image: {ref: 'ghcr.io/acme/trainer:1.4'},
command: ['python', 'train.py'],
workdir: '/app',
env: {EPOCHS: '3'},
gpu: {type: 'B300', count: 8},
timeout: 36000,
queue_timeout: 1800
})
};
fetch('https://api.telnyx.com/v2/ai/sandboxes', 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",
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([
'name' => 'train-run-42',
'tags' => [
'project' => 'llm-ft'
],
'image' => [
'ref' => 'ghcr.io/acme/trainer:1.4'
],
'command' => [
'python',
'train.py'
],
'workdir' => '/app',
'env' => [
'EPOCHS' => '3'
],
'gpu' => [
'type' => 'B300',
'count' => 8
],
'timeout' => 36000,
'queue_timeout' => 1800
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.telnyx.com/v2/ai/sandboxes"
payload := strings.NewReader("{\n \"name\": \"train-run-42\",\n \"tags\": {\n \"project\": \"llm-ft\"\n },\n \"image\": {\n \"ref\": \"ghcr.io/acme/trainer:1.4\"\n },\n \"command\": [\n \"python\",\n \"train.py\"\n ],\n \"workdir\": \"/app\",\n \"env\": {\n \"EPOCHS\": \"3\"\n },\n \"gpu\": {\n \"type\": \"B300\",\n \"count\": 8\n },\n \"timeout\": 36000,\n \"queue_timeout\": 1800\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.telnyx.com/v2/ai/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"train-run-42\",\n \"tags\": {\n \"project\": \"llm-ft\"\n },\n \"image\": {\n \"ref\": \"ghcr.io/acme/trainer:1.4\"\n },\n \"command\": [\n \"python\",\n \"train.py\"\n ],\n \"workdir\": \"/app\",\n \"env\": {\n \"EPOCHS\": \"3\"\n },\n \"gpu\": {\n \"type\": \"B300\",\n \"count\": 8\n },\n \"timeout\": 36000,\n \"queue_timeout\": 1800\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/ai/sandboxes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"train-run-42\",\n \"tags\": {\n \"project\": \"llm-ft\"\n },\n \"image\": {\n \"ref\": \"ghcr.io/acme/trainer:1.4\"\n },\n \"command\": [\n \"python\",\n \"train.py\"\n ],\n \"workdir\": \"/app\",\n \"env\": {\n \"EPOCHS\": \"3\"\n },\n \"gpu\": {\n \"type\": \"B300\",\n \"count\": 8\n },\n \"timeout\": 36000,\n \"queue_timeout\": 1800\n}"
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": "queued",
"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": null,
"logs_incomplete": false,
"logs_incomplete_reason": null,
"resolved": null,
"termination_reason": null,
"termination_message": null,
"exit_code": null,
"created_at": "2026-11-13T10:00:00Z",
"started_at": null,
"terminated_at": null
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "Input should be greater than or equal to 1.",
"source": {
"pointer": "/timeout"
}
}
]
}{
"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": [
{
"title": "request_in_progress",
"detail": "A request with this Idempotency-Key is still being processed."
}
]
}{
"errors": [
{
"title": "resources_not_allowed",
"detail": "GPU type `H100` isn't available; see GET /sandbox-gpu-types.",
"source": {
"pointer": "/gpu/type"
}
}
]
}{
"errors": [
{
"title": "quota_exceeded",
"detail": "This sandbox would exceed your organization's GPU limit for B300: limit 8, 8 in use, 8 requested. Contact support to request a higher limit.",
"source": {
"pointer": "/gpu/count"
}
}
]
}{
"errors": [
{
"title": "sandbox_creation_paused",
"detail": "Creating sandboxes is paused; retry later."
}
]
}