curl --request POST \
--url https://api.blaxel.ai/v0/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"name": "my-resource",
"displayName": "My Resource",
"externalId": "my-session-123",
"labels": {}
},
"spec": {
"enabled": true,
"lifecycle": {
"expirationPolicies": [
{
"action": "delete",
"type": "ttl-idle",
"value": "24h"
}
],
"terminatedRetention": "24h"
},
"network": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"egress": {
"gateway": "egress-ip-gw-1",
"mode": "dedicated",
"policies": [
{
"destinations": "[\"api.stripe.com\"]",
"mode": "dedicated",
"name": "payment-apis"
}
]
},
"firewall": {
"rulesets": "[\"proxy\", \"dedicated-ip\"]"
},
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"proxy": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"bypass": "[\"*.s3.amazonaws.com\"]",
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"routing": [
{
"body": "{\"api_key\": \"{{SECRET:stripe-key}}\"}",
"destinations": "[\"api.stripe.com\"]",
"headers": "{\"Authorization\": \"Bearer {{SECRET:stripe-key}}\"}",
"secrets": "{\"stripe-key\": \"sk-live-abc123...\"}"
}
]
},
"subnet": "default"
},
"region": "us-pdx-1",
"runtime": {
"envs": [
{
"name": "MY_ENV_VAR",
"secret": true,
"value": "my-value"
}
],
"expires": "2025-12-31T23:59:59Z",
"extraArgs": {},
"image": "blaxel/base-image:latest",
"memory": 4096,
"ports": [
{
"target": 8080,
"name": "http",
"protocol": "HTTP"
}
],
"terminationGracePeriodSeconds": 30,
"ttl": "24h"
},
"volumes": [
{
"mountPath": "/mnt/data",
"name": "my-volume",
"readOnly": false
}
],
"vpc": "default"
}
}
'import requests
url = "https://api.blaxel.ai/v0/sandboxes"
payload = {
"metadata": {
"name": "my-resource",
"displayName": "My Resource",
"externalId": "my-session-123",
"labels": {}
},
"spec": {
"enabled": True,
"lifecycle": {
"expirationPolicies": [
{
"action": "delete",
"type": "ttl-idle",
"value": "24h"
}
],
"terminatedRetention": "24h"
},
"network": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"egress": {
"gateway": "egress-ip-gw-1",
"mode": "dedicated",
"policies": [
{
"destinations": "[\"api.stripe.com\"]",
"mode": "dedicated",
"name": "payment-apis"
}
]
},
"firewall": { "rulesets": "[\"proxy\", \"dedicated-ip\"]" },
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"proxy": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"bypass": "[\"*.s3.amazonaws.com\"]",
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"routing": [
{
"body": "{\"api_key\": \"{{SECRET:stripe-key}}\"}",
"destinations": "[\"api.stripe.com\"]",
"headers": "{\"Authorization\": \"Bearer {{SECRET:stripe-key}}\"}",
"secrets": "{\"stripe-key\": \"sk-live-abc123...\"}"
}
]
},
"subnet": "default"
},
"region": "us-pdx-1",
"runtime": {
"envs": [
{
"name": "MY_ENV_VAR",
"secret": True,
"value": "my-value"
}
],
"expires": "2025-12-31T23:59:59Z",
"extraArgs": {},
"image": "blaxel/base-image:latest",
"memory": 4096,
"ports": [
{
"target": 8080,
"name": "http",
"protocol": "HTTP"
}
],
"terminationGracePeriodSeconds": 30,
"ttl": "24h"
},
"volumes": [
{
"mountPath": "/mnt/data",
"name": "my-volume",
"readOnly": False
}
],
"vpc": "default"
}
}
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({
metadata: {
name: 'my-resource',
displayName: 'My Resource',
externalId: 'my-session-123',
labels: {}
},
spec: {
enabled: true,
lifecycle: {
expirationPolicies: [{action: 'delete', type: 'ttl-idle', value: '24h'}],
terminatedRetention: '24h'
},
network: {
allowedDomains: '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
egress: {
gateway: 'egress-ip-gw-1',
mode: 'dedicated',
policies: [{destinations: '["api.stripe.com"]', mode: 'dedicated', name: 'payment-apis'}]
},
firewall: {rulesets: '["proxy", "dedicated-ip"]'},
forbiddenDomains: '["*.malware.com", "evil.example.org"]',
proxy: {
allowedDomains: '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
bypass: '["*.s3.amazonaws.com"]',
forbiddenDomains: '["*.malware.com", "evil.example.org"]',
routing: [
{
body: JSON.stringify('{"api_key": "{{SECRET:stripe-key}}"}'),
destinations: '["api.stripe.com"]',
headers: '{"Authorization": "Bearer {{SECRET:stripe-key}}"}',
secrets: '{"stripe-key": "sk-live-abc123..."}'
}
]
},
subnet: 'default'
},
region: 'us-pdx-1',
runtime: {
envs: [{name: 'MY_ENV_VAR', secret: true, value: 'my-value'}],
expires: '2025-12-31T23:59:59Z',
extraArgs: {},
image: 'blaxel/base-image:latest',
memory: 4096,
ports: [{target: 8080, name: 'http', protocol: 'HTTP'}],
terminationGracePeriodSeconds: 30,
ttl: '24h'
},
volumes: [{mountPath: '/mnt/data', name: 'my-volume', readOnly: false}],
vpc: 'default'
}
})
};
fetch('https://api.blaxel.ai/v0/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.blaxel.ai/v0/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([
'metadata' => [
'name' => 'my-resource',
'displayName' => 'My Resource',
'externalId' => 'my-session-123',
'labels' => [
]
],
'spec' => [
'enabled' => true,
'lifecycle' => [
'expirationPolicies' => [
[
'action' => 'delete',
'type' => 'ttl-idle',
'value' => '24h'
]
],
'terminatedRetention' => '24h'
],
'network' => [
'allowedDomains' => '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
'egress' => [
'gateway' => 'egress-ip-gw-1',
'mode' => 'dedicated',
'policies' => [
[
'destinations' => '["api.stripe.com"]',
'mode' => 'dedicated',
'name' => 'payment-apis'
]
]
],
'firewall' => [
'rulesets' => '["proxy", "dedicated-ip"]'
],
'forbiddenDomains' => '["*.malware.com", "evil.example.org"]',
'proxy' => [
'allowedDomains' => '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
'bypass' => '["*.s3.amazonaws.com"]',
'forbiddenDomains' => '["*.malware.com", "evil.example.org"]',
'routing' => [
[
'body' => '{"api_key": "{{SECRET:stripe-key}}"}',
'destinations' => '["api.stripe.com"]',
'headers' => '{"Authorization": "Bearer {{SECRET:stripe-key}}"}',
'secrets' => '{"stripe-key": "sk-live-abc123..."}'
]
]
],
'subnet' => 'default'
],
'region' => 'us-pdx-1',
'runtime' => [
'envs' => [
[
'name' => 'MY_ENV_VAR',
'secret' => true,
'value' => 'my-value'
]
],
'expires' => '2025-12-31T23:59:59Z',
'extraArgs' => [
],
'image' => 'blaxel/base-image:latest',
'memory' => 4096,
'ports' => [
[
'target' => 8080,
'name' => 'http',
'protocol' => 'HTTP'
]
],
'terminationGracePeriodSeconds' => 30,
'ttl' => '24h'
],
'volumes' => [
[
'mountPath' => '/mnt/data',
'name' => 'my-volume',
'readOnly' => false
]
],
'vpc' => 'default'
]
]),
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.blaxel.ai/v0/sandboxes"
payload := strings.NewReader("{\n \"metadata\": {\n \"name\": \"my-resource\",\n \"displayName\": \"My Resource\",\n \"externalId\": \"my-session-123\",\n \"labels\": {}\n },\n \"spec\": {\n \"enabled\": true,\n \"lifecycle\": {\n \"expirationPolicies\": [\n {\n \"action\": \"delete\",\n \"type\": \"ttl-idle\",\n \"value\": \"24h\"\n }\n ],\n \"terminatedRetention\": \"24h\"\n },\n \"network\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"egress\": {\n \"gateway\": \"egress-ip-gw-1\",\n \"mode\": \"dedicated\",\n \"policies\": [\n {\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"mode\": \"dedicated\",\n \"name\": \"payment-apis\"\n }\n ]\n },\n \"firewall\": {\n \"rulesets\": \"[\\\"proxy\\\", \\\"dedicated-ip\\\"]\"\n },\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"proxy\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"bypass\": \"[\\\"*.s3.amazonaws.com\\\"]\",\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"routing\": [\n {\n \"body\": \"{\\\"api_key\\\": \\\"{{SECRET:stripe-key}}\\\"}\",\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"headers\": \"{\\\"Authorization\\\": \\\"Bearer {{SECRET:stripe-key}}\\\"}\",\n \"secrets\": \"{\\\"stripe-key\\\": \\\"sk-live-abc123...\\\"}\"\n }\n ]\n },\n \"subnet\": \"default\"\n },\n \"region\": \"us-pdx-1\",\n \"runtime\": {\n \"envs\": [\n {\n \"name\": \"MY_ENV_VAR\",\n \"secret\": true,\n \"value\": \"my-value\"\n }\n ],\n \"expires\": \"2025-12-31T23:59:59Z\",\n \"extraArgs\": {},\n \"image\": \"blaxel/base-image:latest\",\n \"memory\": 4096,\n \"ports\": [\n {\n \"target\": 8080,\n \"name\": \"http\",\n \"protocol\": \"HTTP\"\n }\n ],\n \"terminationGracePeriodSeconds\": 30,\n \"ttl\": \"24h\"\n },\n \"volumes\": [\n {\n \"mountPath\": \"/mnt/data\",\n \"name\": \"my-volume\",\n \"readOnly\": false\n }\n ],\n \"vpc\": \"default\"\n }\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.blaxel.ai/v0/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"name\": \"my-resource\",\n \"displayName\": \"My Resource\",\n \"externalId\": \"my-session-123\",\n \"labels\": {}\n },\n \"spec\": {\n \"enabled\": true,\n \"lifecycle\": {\n \"expirationPolicies\": [\n {\n \"action\": \"delete\",\n \"type\": \"ttl-idle\",\n \"value\": \"24h\"\n }\n ],\n \"terminatedRetention\": \"24h\"\n },\n \"network\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"egress\": {\n \"gateway\": \"egress-ip-gw-1\",\n \"mode\": \"dedicated\",\n \"policies\": [\n {\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"mode\": \"dedicated\",\n \"name\": \"payment-apis\"\n }\n ]\n },\n \"firewall\": {\n \"rulesets\": \"[\\\"proxy\\\", \\\"dedicated-ip\\\"]\"\n },\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"proxy\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"bypass\": \"[\\\"*.s3.amazonaws.com\\\"]\",\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"routing\": [\n {\n \"body\": \"{\\\"api_key\\\": \\\"{{SECRET:stripe-key}}\\\"}\",\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"headers\": \"{\\\"Authorization\\\": \\\"Bearer {{SECRET:stripe-key}}\\\"}\",\n \"secrets\": \"{\\\"stripe-key\\\": \\\"sk-live-abc123...\\\"}\"\n }\n ]\n },\n \"subnet\": \"default\"\n },\n \"region\": \"us-pdx-1\",\n \"runtime\": {\n \"envs\": [\n {\n \"name\": \"MY_ENV_VAR\",\n \"secret\": true,\n \"value\": \"my-value\"\n }\n ],\n \"expires\": \"2025-12-31T23:59:59Z\",\n \"extraArgs\": {},\n \"image\": \"blaxel/base-image:latest\",\n \"memory\": 4096,\n \"ports\": [\n {\n \"target\": 8080,\n \"name\": \"http\",\n \"protocol\": \"HTTP\"\n }\n ],\n \"terminationGracePeriodSeconds\": 30,\n \"ttl\": \"24h\"\n },\n \"volumes\": [\n {\n \"mountPath\": \"/mnt/data\",\n \"name\": \"my-volume\",\n \"readOnly\": false\n }\n ],\n \"vpc\": \"default\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.blaxel.ai/v0/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 \"metadata\": {\n \"name\": \"my-resource\",\n \"displayName\": \"My Resource\",\n \"externalId\": \"my-session-123\",\n \"labels\": {}\n },\n \"spec\": {\n \"enabled\": true,\n \"lifecycle\": {\n \"expirationPolicies\": [\n {\n \"action\": \"delete\",\n \"type\": \"ttl-idle\",\n \"value\": \"24h\"\n }\n ],\n \"terminatedRetention\": \"24h\"\n },\n \"network\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"egress\": {\n \"gateway\": \"egress-ip-gw-1\",\n \"mode\": \"dedicated\",\n \"policies\": [\n {\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"mode\": \"dedicated\",\n \"name\": \"payment-apis\"\n }\n ]\n },\n \"firewall\": {\n \"rulesets\": \"[\\\"proxy\\\", \\\"dedicated-ip\\\"]\"\n },\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"proxy\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"bypass\": \"[\\\"*.s3.amazonaws.com\\\"]\",\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"routing\": [\n {\n \"body\": \"{\\\"api_key\\\": \\\"{{SECRET:stripe-key}}\\\"}\",\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"headers\": \"{\\\"Authorization\\\": \\\"Bearer {{SECRET:stripe-key}}\\\"}\",\n \"secrets\": \"{\\\"stripe-key\\\": \\\"sk-live-abc123...\\\"}\"\n }\n ]\n },\n \"subnet\": \"default\"\n },\n \"region\": \"us-pdx-1\",\n \"runtime\": {\n \"envs\": [\n {\n \"name\": \"MY_ENV_VAR\",\n \"secret\": true,\n \"value\": \"my-value\"\n }\n ],\n \"expires\": \"2025-12-31T23:59:59Z\",\n \"extraArgs\": {},\n \"image\": \"blaxel/base-image:latest\",\n \"memory\": 4096,\n \"ports\": [\n {\n \"target\": 8080,\n \"name\": \"http\",\n \"protocol\": \"HTTP\"\n }\n ],\n \"terminationGracePeriodSeconds\": 30,\n \"ttl\": \"24h\"\n },\n \"volumes\": [\n {\n \"mountPath\": \"/mnt/data\",\n \"name\": \"my-volume\",\n \"readOnly\": false\n }\n ],\n \"vpc\": \"default\"\n }\n}"
response = http.request(request)
puts response.read_body{
"metadata": {
"name": "my-resource",
"createdAt": "<string>",
"updatedAt": "<string>",
"createdBy": "<string>",
"updatedBy": "<string>",
"displayName": "My Resource",
"externalId": "my-session-123",
"labels": {},
"plan": "<string>",
"url": "<string>",
"workspace": "<string>"
},
"spec": {
"enabled": true,
"lifecycle": {
"expirationPolicies": [
{
"action": "delete",
"type": "ttl-idle",
"value": "24h"
}
],
"terminatedRetention": "24h"
},
"network": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"egress": {
"gateway": "egress-ip-gw-1",
"mode": "dedicated",
"policies": [
{
"destinations": "[\"api.stripe.com\"]",
"mode": "dedicated",
"name": "payment-apis"
}
]
},
"firewall": {
"rulesets": "[\"proxy\", \"dedicated-ip\"]"
},
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"proxy": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"bypass": "[\"*.s3.amazonaws.com\"]",
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"routing": [
{
"body": "{\"api_key\": \"{{SECRET:stripe-key}}\"}",
"destinations": "[\"api.stripe.com\"]",
"headers": "{\"Authorization\": \"Bearer {{SECRET:stripe-key}}\"}",
"secrets": "{\"stripe-key\": \"sk-live-abc123...\"}"
}
]
},
"subnet": "default"
},
"region": "us-pdx-1",
"runtime": {
"envs": [
{
"name": "MY_ENV_VAR",
"secret": true,
"value": "my-value"
}
],
"expires": "2025-12-31T23:59:59Z",
"extraArgs": {},
"image": "blaxel/base-image:latest",
"memory": 4096,
"ports": [
{
"target": 8080,
"name": "http",
"protocol": "HTTP"
}
],
"terminationGracePeriodSeconds": 30,
"ttl": "24h"
},
"volumes": [
{
"mountPath": "/mnt/data",
"name": "my-volume",
"readOnly": false
}
],
"vpc": "default"
},
"events": [
{
"canaryRevision": "<string>",
"message": "Deployment successful",
"revision": "rev-abc123",
"status": "DEPLOYED",
"time": "2025-01-15T10:30:00Z",
"type": "deployment"
}
],
"expiresIn": 123,
"lastUsedAt": "<string>"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}Create sandbox
Creates a new sandbox VM for secure AI code execution. Sandboxes automatically scale to zero when idle and resume instantly, preserving memory state including running processes and filesystem.
curl --request POST \
--url https://api.blaxel.ai/v0/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"name": "my-resource",
"displayName": "My Resource",
"externalId": "my-session-123",
"labels": {}
},
"spec": {
"enabled": true,
"lifecycle": {
"expirationPolicies": [
{
"action": "delete",
"type": "ttl-idle",
"value": "24h"
}
],
"terminatedRetention": "24h"
},
"network": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"egress": {
"gateway": "egress-ip-gw-1",
"mode": "dedicated",
"policies": [
{
"destinations": "[\"api.stripe.com\"]",
"mode": "dedicated",
"name": "payment-apis"
}
]
},
"firewall": {
"rulesets": "[\"proxy\", \"dedicated-ip\"]"
},
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"proxy": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"bypass": "[\"*.s3.amazonaws.com\"]",
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"routing": [
{
"body": "{\"api_key\": \"{{SECRET:stripe-key}}\"}",
"destinations": "[\"api.stripe.com\"]",
"headers": "{\"Authorization\": \"Bearer {{SECRET:stripe-key}}\"}",
"secrets": "{\"stripe-key\": \"sk-live-abc123...\"}"
}
]
},
"subnet": "default"
},
"region": "us-pdx-1",
"runtime": {
"envs": [
{
"name": "MY_ENV_VAR",
"secret": true,
"value": "my-value"
}
],
"expires": "2025-12-31T23:59:59Z",
"extraArgs": {},
"image": "blaxel/base-image:latest",
"memory": 4096,
"ports": [
{
"target": 8080,
"name": "http",
"protocol": "HTTP"
}
],
"terminationGracePeriodSeconds": 30,
"ttl": "24h"
},
"volumes": [
{
"mountPath": "/mnt/data",
"name": "my-volume",
"readOnly": false
}
],
"vpc": "default"
}
}
'import requests
url = "https://api.blaxel.ai/v0/sandboxes"
payload = {
"metadata": {
"name": "my-resource",
"displayName": "My Resource",
"externalId": "my-session-123",
"labels": {}
},
"spec": {
"enabled": True,
"lifecycle": {
"expirationPolicies": [
{
"action": "delete",
"type": "ttl-idle",
"value": "24h"
}
],
"terminatedRetention": "24h"
},
"network": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"egress": {
"gateway": "egress-ip-gw-1",
"mode": "dedicated",
"policies": [
{
"destinations": "[\"api.stripe.com\"]",
"mode": "dedicated",
"name": "payment-apis"
}
]
},
"firewall": { "rulesets": "[\"proxy\", \"dedicated-ip\"]" },
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"proxy": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"bypass": "[\"*.s3.amazonaws.com\"]",
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"routing": [
{
"body": "{\"api_key\": \"{{SECRET:stripe-key}}\"}",
"destinations": "[\"api.stripe.com\"]",
"headers": "{\"Authorization\": \"Bearer {{SECRET:stripe-key}}\"}",
"secrets": "{\"stripe-key\": \"sk-live-abc123...\"}"
}
]
},
"subnet": "default"
},
"region": "us-pdx-1",
"runtime": {
"envs": [
{
"name": "MY_ENV_VAR",
"secret": True,
"value": "my-value"
}
],
"expires": "2025-12-31T23:59:59Z",
"extraArgs": {},
"image": "blaxel/base-image:latest",
"memory": 4096,
"ports": [
{
"target": 8080,
"name": "http",
"protocol": "HTTP"
}
],
"terminationGracePeriodSeconds": 30,
"ttl": "24h"
},
"volumes": [
{
"mountPath": "/mnt/data",
"name": "my-volume",
"readOnly": False
}
],
"vpc": "default"
}
}
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({
metadata: {
name: 'my-resource',
displayName: 'My Resource',
externalId: 'my-session-123',
labels: {}
},
spec: {
enabled: true,
lifecycle: {
expirationPolicies: [{action: 'delete', type: 'ttl-idle', value: '24h'}],
terminatedRetention: '24h'
},
network: {
allowedDomains: '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
egress: {
gateway: 'egress-ip-gw-1',
mode: 'dedicated',
policies: [{destinations: '["api.stripe.com"]', mode: 'dedicated', name: 'payment-apis'}]
},
firewall: {rulesets: '["proxy", "dedicated-ip"]'},
forbiddenDomains: '["*.malware.com", "evil.example.org"]',
proxy: {
allowedDomains: '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
bypass: '["*.s3.amazonaws.com"]',
forbiddenDomains: '["*.malware.com", "evil.example.org"]',
routing: [
{
body: JSON.stringify('{"api_key": "{{SECRET:stripe-key}}"}'),
destinations: '["api.stripe.com"]',
headers: '{"Authorization": "Bearer {{SECRET:stripe-key}}"}',
secrets: '{"stripe-key": "sk-live-abc123..."}'
}
]
},
subnet: 'default'
},
region: 'us-pdx-1',
runtime: {
envs: [{name: 'MY_ENV_VAR', secret: true, value: 'my-value'}],
expires: '2025-12-31T23:59:59Z',
extraArgs: {},
image: 'blaxel/base-image:latest',
memory: 4096,
ports: [{target: 8080, name: 'http', protocol: 'HTTP'}],
terminationGracePeriodSeconds: 30,
ttl: '24h'
},
volumes: [{mountPath: '/mnt/data', name: 'my-volume', readOnly: false}],
vpc: 'default'
}
})
};
fetch('https://api.blaxel.ai/v0/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.blaxel.ai/v0/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([
'metadata' => [
'name' => 'my-resource',
'displayName' => 'My Resource',
'externalId' => 'my-session-123',
'labels' => [
]
],
'spec' => [
'enabled' => true,
'lifecycle' => [
'expirationPolicies' => [
[
'action' => 'delete',
'type' => 'ttl-idle',
'value' => '24h'
]
],
'terminatedRetention' => '24h'
],
'network' => [
'allowedDomains' => '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
'egress' => [
'gateway' => 'egress-ip-gw-1',
'mode' => 'dedicated',
'policies' => [
[
'destinations' => '["api.stripe.com"]',
'mode' => 'dedicated',
'name' => 'payment-apis'
]
]
],
'firewall' => [
'rulesets' => '["proxy", "dedicated-ip"]'
],
'forbiddenDomains' => '["*.malware.com", "evil.example.org"]',
'proxy' => [
'allowedDomains' => '["api.stripe.com", "api.openai.com", "*.s3.amazonaws.com"]',
'bypass' => '["*.s3.amazonaws.com"]',
'forbiddenDomains' => '["*.malware.com", "evil.example.org"]',
'routing' => [
[
'body' => '{"api_key": "{{SECRET:stripe-key}}"}',
'destinations' => '["api.stripe.com"]',
'headers' => '{"Authorization": "Bearer {{SECRET:stripe-key}}"}',
'secrets' => '{"stripe-key": "sk-live-abc123..."}'
]
]
],
'subnet' => 'default'
],
'region' => 'us-pdx-1',
'runtime' => [
'envs' => [
[
'name' => 'MY_ENV_VAR',
'secret' => true,
'value' => 'my-value'
]
],
'expires' => '2025-12-31T23:59:59Z',
'extraArgs' => [
],
'image' => 'blaxel/base-image:latest',
'memory' => 4096,
'ports' => [
[
'target' => 8080,
'name' => 'http',
'protocol' => 'HTTP'
]
],
'terminationGracePeriodSeconds' => 30,
'ttl' => '24h'
],
'volumes' => [
[
'mountPath' => '/mnt/data',
'name' => 'my-volume',
'readOnly' => false
]
],
'vpc' => 'default'
]
]),
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.blaxel.ai/v0/sandboxes"
payload := strings.NewReader("{\n \"metadata\": {\n \"name\": \"my-resource\",\n \"displayName\": \"My Resource\",\n \"externalId\": \"my-session-123\",\n \"labels\": {}\n },\n \"spec\": {\n \"enabled\": true,\n \"lifecycle\": {\n \"expirationPolicies\": [\n {\n \"action\": \"delete\",\n \"type\": \"ttl-idle\",\n \"value\": \"24h\"\n }\n ],\n \"terminatedRetention\": \"24h\"\n },\n \"network\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"egress\": {\n \"gateway\": \"egress-ip-gw-1\",\n \"mode\": \"dedicated\",\n \"policies\": [\n {\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"mode\": \"dedicated\",\n \"name\": \"payment-apis\"\n }\n ]\n },\n \"firewall\": {\n \"rulesets\": \"[\\\"proxy\\\", \\\"dedicated-ip\\\"]\"\n },\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"proxy\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"bypass\": \"[\\\"*.s3.amazonaws.com\\\"]\",\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"routing\": [\n {\n \"body\": \"{\\\"api_key\\\": \\\"{{SECRET:stripe-key}}\\\"}\",\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"headers\": \"{\\\"Authorization\\\": \\\"Bearer {{SECRET:stripe-key}}\\\"}\",\n \"secrets\": \"{\\\"stripe-key\\\": \\\"sk-live-abc123...\\\"}\"\n }\n ]\n },\n \"subnet\": \"default\"\n },\n \"region\": \"us-pdx-1\",\n \"runtime\": {\n \"envs\": [\n {\n \"name\": \"MY_ENV_VAR\",\n \"secret\": true,\n \"value\": \"my-value\"\n }\n ],\n \"expires\": \"2025-12-31T23:59:59Z\",\n \"extraArgs\": {},\n \"image\": \"blaxel/base-image:latest\",\n \"memory\": 4096,\n \"ports\": [\n {\n \"target\": 8080,\n \"name\": \"http\",\n \"protocol\": \"HTTP\"\n }\n ],\n \"terminationGracePeriodSeconds\": 30,\n \"ttl\": \"24h\"\n },\n \"volumes\": [\n {\n \"mountPath\": \"/mnt/data\",\n \"name\": \"my-volume\",\n \"readOnly\": false\n }\n ],\n \"vpc\": \"default\"\n }\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.blaxel.ai/v0/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"name\": \"my-resource\",\n \"displayName\": \"My Resource\",\n \"externalId\": \"my-session-123\",\n \"labels\": {}\n },\n \"spec\": {\n \"enabled\": true,\n \"lifecycle\": {\n \"expirationPolicies\": [\n {\n \"action\": \"delete\",\n \"type\": \"ttl-idle\",\n \"value\": \"24h\"\n }\n ],\n \"terminatedRetention\": \"24h\"\n },\n \"network\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"egress\": {\n \"gateway\": \"egress-ip-gw-1\",\n \"mode\": \"dedicated\",\n \"policies\": [\n {\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"mode\": \"dedicated\",\n \"name\": \"payment-apis\"\n }\n ]\n },\n \"firewall\": {\n \"rulesets\": \"[\\\"proxy\\\", \\\"dedicated-ip\\\"]\"\n },\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"proxy\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"bypass\": \"[\\\"*.s3.amazonaws.com\\\"]\",\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"routing\": [\n {\n \"body\": \"{\\\"api_key\\\": \\\"{{SECRET:stripe-key}}\\\"}\",\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"headers\": \"{\\\"Authorization\\\": \\\"Bearer {{SECRET:stripe-key}}\\\"}\",\n \"secrets\": \"{\\\"stripe-key\\\": \\\"sk-live-abc123...\\\"}\"\n }\n ]\n },\n \"subnet\": \"default\"\n },\n \"region\": \"us-pdx-1\",\n \"runtime\": {\n \"envs\": [\n {\n \"name\": \"MY_ENV_VAR\",\n \"secret\": true,\n \"value\": \"my-value\"\n }\n ],\n \"expires\": \"2025-12-31T23:59:59Z\",\n \"extraArgs\": {},\n \"image\": \"blaxel/base-image:latest\",\n \"memory\": 4096,\n \"ports\": [\n {\n \"target\": 8080,\n \"name\": \"http\",\n \"protocol\": \"HTTP\"\n }\n ],\n \"terminationGracePeriodSeconds\": 30,\n \"ttl\": \"24h\"\n },\n \"volumes\": [\n {\n \"mountPath\": \"/mnt/data\",\n \"name\": \"my-volume\",\n \"readOnly\": false\n }\n ],\n \"vpc\": \"default\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.blaxel.ai/v0/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 \"metadata\": {\n \"name\": \"my-resource\",\n \"displayName\": \"My Resource\",\n \"externalId\": \"my-session-123\",\n \"labels\": {}\n },\n \"spec\": {\n \"enabled\": true,\n \"lifecycle\": {\n \"expirationPolicies\": [\n {\n \"action\": \"delete\",\n \"type\": \"ttl-idle\",\n \"value\": \"24h\"\n }\n ],\n \"terminatedRetention\": \"24h\"\n },\n \"network\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"egress\": {\n \"gateway\": \"egress-ip-gw-1\",\n \"mode\": \"dedicated\",\n \"policies\": [\n {\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"mode\": \"dedicated\",\n \"name\": \"payment-apis\"\n }\n ]\n },\n \"firewall\": {\n \"rulesets\": \"[\\\"proxy\\\", \\\"dedicated-ip\\\"]\"\n },\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"proxy\": {\n \"allowedDomains\": \"[\\\"api.stripe.com\\\", \\\"api.openai.com\\\", \\\"*.s3.amazonaws.com\\\"]\",\n \"bypass\": \"[\\\"*.s3.amazonaws.com\\\"]\",\n \"forbiddenDomains\": \"[\\\"*.malware.com\\\", \\\"evil.example.org\\\"]\",\n \"routing\": [\n {\n \"body\": \"{\\\"api_key\\\": \\\"{{SECRET:stripe-key}}\\\"}\",\n \"destinations\": \"[\\\"api.stripe.com\\\"]\",\n \"headers\": \"{\\\"Authorization\\\": \\\"Bearer {{SECRET:stripe-key}}\\\"}\",\n \"secrets\": \"{\\\"stripe-key\\\": \\\"sk-live-abc123...\\\"}\"\n }\n ]\n },\n \"subnet\": \"default\"\n },\n \"region\": \"us-pdx-1\",\n \"runtime\": {\n \"envs\": [\n {\n \"name\": \"MY_ENV_VAR\",\n \"secret\": true,\n \"value\": \"my-value\"\n }\n ],\n \"expires\": \"2025-12-31T23:59:59Z\",\n \"extraArgs\": {},\n \"image\": \"blaxel/base-image:latest\",\n \"memory\": 4096,\n \"ports\": [\n {\n \"target\": 8080,\n \"name\": \"http\",\n \"protocol\": \"HTTP\"\n }\n ],\n \"terminationGracePeriodSeconds\": 30,\n \"ttl\": \"24h\"\n },\n \"volumes\": [\n {\n \"mountPath\": \"/mnt/data\",\n \"name\": \"my-volume\",\n \"readOnly\": false\n }\n ],\n \"vpc\": \"default\"\n }\n}"
response = http.request(request)
puts response.read_body{
"metadata": {
"name": "my-resource",
"createdAt": "<string>",
"updatedAt": "<string>",
"createdBy": "<string>",
"updatedBy": "<string>",
"displayName": "My Resource",
"externalId": "my-session-123",
"labels": {},
"plan": "<string>",
"url": "<string>",
"workspace": "<string>"
},
"spec": {
"enabled": true,
"lifecycle": {
"expirationPolicies": [
{
"action": "delete",
"type": "ttl-idle",
"value": "24h"
}
],
"terminatedRetention": "24h"
},
"network": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"egress": {
"gateway": "egress-ip-gw-1",
"mode": "dedicated",
"policies": [
{
"destinations": "[\"api.stripe.com\"]",
"mode": "dedicated",
"name": "payment-apis"
}
]
},
"firewall": {
"rulesets": "[\"proxy\", \"dedicated-ip\"]"
},
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"proxy": {
"allowedDomains": "[\"api.stripe.com\", \"api.openai.com\", \"*.s3.amazonaws.com\"]",
"bypass": "[\"*.s3.amazonaws.com\"]",
"forbiddenDomains": "[\"*.malware.com\", \"evil.example.org\"]",
"routing": [
{
"body": "{\"api_key\": \"{{SECRET:stripe-key}}\"}",
"destinations": "[\"api.stripe.com\"]",
"headers": "{\"Authorization\": \"Bearer {{SECRET:stripe-key}}\"}",
"secrets": "{\"stripe-key\": \"sk-live-abc123...\"}"
}
]
},
"subnet": "default"
},
"region": "us-pdx-1",
"runtime": {
"envs": [
{
"name": "MY_ENV_VAR",
"secret": true,
"value": "my-value"
}
],
"expires": "2025-12-31T23:59:59Z",
"extraArgs": {},
"image": "blaxel/base-image:latest",
"memory": 4096,
"ports": [
{
"target": 8080,
"name": "http",
"protocol": "HTTP"
}
],
"terminationGracePeriodSeconds": 30,
"ttl": "24h"
},
"volumes": [
{
"mountPath": "/mnt/data",
"name": "my-volume",
"readOnly": false
}
],
"vpc": "default"
},
"events": [
{
"canaryRevision": "<string>",
"message": "Deployment successful",
"revision": "rev-abc123",
"status": "DEPLOYED",
"time": "2025-01-15T10:30:00Z",
"type": "deployment"
}
],
"expiresIn": 123,
"lastUsedAt": "<string>"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}{
"code": "INVALID_IMAGE",
"message": "Sandbox image blaxel/dev-ts-app:latest is not supported",
"details": {},
"sandbox_name": "mysandbox",
"status_code": 400,
"step": "validate_and_prepare",
"timestamp": "2025-12-19T22:36:29.336304095Z",
"workspace": "main"
}Authorizations
OAuth2 authentication with JWT tokens
Query Parameters
If true, return existing sandbox instead of 409 error when sandbox exists and is not in FAILED/TERMINATED/TERMINATING state
Body
Lightweight virtual machine for secure AI code execution. Sandboxes resume from standby in under 25ms and automatically scale to zero after inactivity, preserving memory state including running processes and filesystem.
Response
successful operation
Lightweight virtual machine for secure AI code execution. Sandboxes resume from standby in under 25ms and automatically scale to zero after inactivity, preserving memory state including running processes and filesystem.
Common metadata fields shared by all Blaxel resources including name, labels, timestamps, and ownership information
Show child attributes
Show child attributes
Configuration for a sandbox including its image, memory, ports, region, and lifecycle policies
Show child attributes
Show child attributes
Events happening on a resource deployed on Blaxel
Show child attributes
Show child attributes
Time in seconds until the sandbox is automatically deleted based on TTL and lifecycle policies. Only present for sandboxes with lifecycle configured.
Last time the sandbox was used (read-only, managed by the system)
Current state of the sandbox (read-only, managed by the system)
RUNNING, STANDBY Deployment status of a resource deployed on Blaxel
DELETING, TERMINATED, FAILED, DEACTIVATED, DEACTIVATING, UPLOADING, BUILDING, DEPLOYING, DEPLOYED, BUILT Was this page helpful?
