Skip to main content
POST
/
sandboxes
Create a sandbox
curl --request POST \
  --url https://api.tensorlake.ai/sandboxes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "image": "<string>",
  "resources": {
    "cpus": 123,
    "memory_mb": 123,
    "disk_mb": 56320,
    "gpus": [
      {
        "count": 2,
        "model": "<string>"
      }
    ]
  },
  "secret_names": [
    "<string>"
  ],
  "timeout_secs": 1,
  "entrypoint": [
    "<string>"
  ],
  "network": {
    "allow_internet_access": true,
    "allow_out": [
      "<string>"
    ],
    "deny_out": [
      "<string>"
    ]
  },
  "snapshot_id": "<string>",
  "allow_unauthenticated_access": true,
  "exposed_ports": [
    32768
  ],
  "template_id": "<string>",
  "name": "<string>"
}
'
import requests

url = "https://api.tensorlake.ai/sandboxes"

payload = {
"image": "<string>",
"resources": {
"cpus": 123,
"memory_mb": 123,
"disk_mb": 56320,
"gpus": [
{
"count": 2,
"model": "<string>"
}
]
},
"secret_names": ["<string>"],
"timeout_secs": 1,
"entrypoint": ["<string>"],
"network": {
"allow_internet_access": True,
"allow_out": ["<string>"],
"deny_out": ["<string>"]
},
"snapshot_id": "<string>",
"allow_unauthenticated_access": True,
"exposed_ports": [32768],
"template_id": "<string>",
"name": "<string>"
}
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({
image: '<string>',
resources: {
cpus: 123,
memory_mb: 123,
disk_mb: 56320,
gpus: [{count: 2, model: '<string>'}]
},
secret_names: ['<string>'],
timeout_secs: 1,
entrypoint: ['<string>'],
network: {allow_internet_access: true, allow_out: ['<string>'], deny_out: ['<string>']},
snapshot_id: '<string>',
allow_unauthenticated_access: true,
exposed_ports: [32768],
template_id: '<string>',
name: '<string>'
})
};

fetch('https://api.tensorlake.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.tensorlake.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([
'image' => '<string>',
'resources' => [
'cpus' => 123,
'memory_mb' => 123,
'disk_mb' => 56320,
'gpus' => [
[
'count' => 2,
'model' => '<string>'
]
]
],
'secret_names' => [
'<string>'
],
'timeout_secs' => 1,
'entrypoint' => [
'<string>'
],
'network' => [
'allow_internet_access' => true,
'allow_out' => [
'<string>'
],
'deny_out' => [
'<string>'
]
],
'snapshot_id' => '<string>',
'allow_unauthenticated_access' => true,
'exposed_ports' => [
32768
],
'template_id' => '<string>',
'name' => '<string>'
]),
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.tensorlake.ai/sandboxes"

payload := strings.NewReader("{\n \"image\": \"<string>\",\n \"resources\": {\n \"cpus\": 123,\n \"memory_mb\": 123,\n \"disk_mb\": 56320,\n \"gpus\": [\n {\n \"count\": 2,\n \"model\": \"<string>\"\n }\n ]\n },\n \"secret_names\": [\n \"<string>\"\n ],\n \"timeout_secs\": 1,\n \"entrypoint\": [\n \"<string>\"\n ],\n \"network\": {\n \"allow_internet_access\": true,\n \"allow_out\": [\n \"<string>\"\n ],\n \"deny_out\": [\n \"<string>\"\n ]\n },\n \"snapshot_id\": \"<string>\",\n \"allow_unauthenticated_access\": true,\n \"exposed_ports\": [\n 32768\n ],\n \"template_id\": \"<string>\",\n \"name\": \"<string>\"\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.tensorlake.ai/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"<string>\",\n \"resources\": {\n \"cpus\": 123,\n \"memory_mb\": 123,\n \"disk_mb\": 56320,\n \"gpus\": [\n {\n \"count\": 2,\n \"model\": \"<string>\"\n }\n ]\n },\n \"secret_names\": [\n \"<string>\"\n ],\n \"timeout_secs\": 1,\n \"entrypoint\": [\n \"<string>\"\n ],\n \"network\": {\n \"allow_internet_access\": true,\n \"allow_out\": [\n \"<string>\"\n ],\n \"deny_out\": [\n \"<string>\"\n ]\n },\n \"snapshot_id\": \"<string>\",\n \"allow_unauthenticated_access\": true,\n \"exposed_ports\": [\n 32768\n ],\n \"template_id\": \"<string>\",\n \"name\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.tensorlake.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 \"image\": \"<string>\",\n \"resources\": {\n \"cpus\": 123,\n \"memory_mb\": 123,\n \"disk_mb\": 56320,\n \"gpus\": [\n {\n \"count\": 2,\n \"model\": \"<string>\"\n }\n ]\n },\n \"secret_names\": [\n \"<string>\"\n ],\n \"timeout_secs\": 1,\n \"entrypoint\": [\n \"<string>\"\n ],\n \"network\": {\n \"allow_internet_access\": true,\n \"allow_out\": [\n \"<string>\"\n ],\n \"deny_out\": [\n \"<string>\"\n ]\n },\n \"snapshot_id\": \"<string>\",\n \"allow_unauthenticated_access\": true,\n \"exposed_ports\": [\n 32768\n ],\n \"template_id\": \"<string>\",\n \"name\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "sandbox_id": "<string>",
  "ingress_endpoint": "<string>"
}
Launch an ephemeral or named sandbox. The response includes the sandbox’s ingress_endpoint. Prefer it over constructing *.sandbox.tensorlake.ai hostnames yourself when building sandbox-specific URLs in client code.
  • Omit name to create an ephemeral sandbox.
  • Set name to create a named sandbox that supports suspend and resume.
  • Set snapshot_id to restore from a snapshot, or image to boot from a registered Sandbox Image.
  • For fresh creates, if resources.disk_mb is omitted, the sandbox uses the default 10 GB root disk (10240 MiB).
  • With image, resources.disk_mb can be used to grow the root disk at create time (growth-only).
  • With snapshot_id from a filesystem snapshot, resources.disk_mb can be used to grow the root disk at create time (growth-only).

Authorizations

Authorization
string
header
required

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

Body

application/json
image
string

Optional sandbox image name to boot from. When omitted, Tensorlake uses the default managed environment. This can also be a registered Sandbox Image name.

resources
object
secret_names
string[]

Secret names to inject into the sandbox.

timeout_secs
integer<int64>

Sandbox timeout in seconds. 0 requests the maximum allowed by your plan. Plan maximums: Free unverified 3600 (1h), Free verified 7200 (2h), On-Demand 86400 (24h). See tensorlake.ai/pricing for higher limits on committed plans.

Required range: x >= 0
entrypoint
string[]

Optional command to run when the sandbox starts.

network
object
snapshot_id
string

Snapshot to restore from.

allow_unauthenticated_access
boolean

Allow sandbox ingress to route requests without validating auth credentials. The legacy request alias allow_unauthenticated_proxy_access is also accepted.

exposed_ports
integer<int32>[]

Additional sandbox ports that public ingress may route to. When omitted, only the management port 9501 is routable.

Required range: 1 <= x <= 65535
template_id
string

Template identifier to associate with the launched sandbox.

name
string

Optional user-provided sandbox name. When set, the sandbox is named and supports suspend/resume. When omitted, the sandbox is ephemeral.

Response

Sandbox created successfully

sandbox_id
string
required
status
enum<string>
required
Available options:
pending,
running,
snapshotting,
suspending,
suspended,
terminated
pending_reason
enum<string>
Available options:
scheduling,
waiting_for_container,
no_executors_available,
no_resources_available,
pool_at_capacity
ingress_endpoint
string | null

Base ingress origin for this sandbox's current placement.