Skip to main content
POST
Create a sandbox

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Idempotency-Key
string

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.

Required string length: 1 - 255

Body

application/json

A new sandbox. image and gpu are required.

gpu
object
required

The GPU type and a count from its allowed_counts, as listed by GET /ai/sandbox-gpu-types. Currently that's the node's GPU count, so the sandbox gets a whole node of that type, with the type's CPU, memory and disk.

image
object
required

The container image to run. The image must be publicly pullable and have a linux/amd64 variant.

block_network
boolean
default:false

No network at all, not even DNS (network mode blocked). Can't be combined with cidr_allowlist.

cidr_allowlist
string[] | null

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.

Minimum array length: 1
command
string[] | null

Full argv to run, replacing the image's ENTRYPOINT and CMD. Omit it to run the image's own ENTRYPOINT + CMD; if the image has neither, the sandbox ends with termination_reason: no_command.

Minimum array length: 1
env
object

Environment variables, on top of the image's. Names must be POSIX names and can't start with TELNYX_SANDBOX_; at most 256 variables, 32 KiB each and 256 KiB in total (else invalid_env).

idle_timeout
integer | null

End 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.

Required range: x >= 1
log_bucket
string | null

Your 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.

Required string length: 3 - 63
Pattern: ^[a-z0-9][a-z0-9.-]*[a-z0-9]$
name
string | null

Optional name, unique among your non-terminated sandboxes (else name_conflict); reusable once the sandbox holding it is terminated. Look it up with GET /ai/sandboxes?name=….

Required string length: 1 - 64
Pattern: ^[A-Za-z0-9._-]+$
queue_timeout
integer
default:600

How long to wait before placement, in seconds: resolving the image, waiting for capacity and preparing GPUs all count. Then the sandbox ends with queue_timeout, so with 0 it always does. Queued and preparing time isn't billed.

Required range: 0 <= x <= 86400
readiness_probe
TCP port probe · object

How to tell the sandbox is ready (see ready).

tags
object

Your own key/value labels, e.g. {"project": "llm-ft"}. At most 20 tags; keys 1–63 characters, values up to 255. Filter on them with GET /ai/sandboxes?tag[<key>]=<value>.

timeout
integer | null
default:300

Maximum lifetime in seconds. Omitted: 300 s. null: no limit; the sandbox runs until it's terminated. There's no maximum. Send an explicit null for no limit: a client that drops null fields gets the 300 s default.

Required range: x >= 1
workdir
string | null

Absolute working directory (else invalid_workdir). Defaults to the image's WorkingDir, then /. Execs default to it too.

Maximum string length: 4096
Pattern: ^/

Response

The sandbox, in state queued.

data
object
required

A sandbox: one container image running in its own virtual machine. Terminated sandboxes stay readable for at least 30 days.