cURL
curl --request POST \
--url https://api.example.com/api/v1/sandboxes \
--header 'Content-Type: application/json' \
--data '
{
"image": "node:22",
"timeoutMs": 600000,
"env": {
"NODE_ENV": "production",
"API_KEY": "secret"
},
"volumes": {
"/workspace": "my_packages",
"/cache": {
"name": "build_cache",
"sizeGb": 5
}
}
}
'import requests
url = "https://api.example.com/api/v1/sandboxes"
payload = {
"image": "node:22",
"timeoutMs": 600000,
"env": {
"NODE_ENV": "production",
"API_KEY": "secret"
},
"volumes": {
"/workspace": "my_packages",
"/cache": {
"name": "build_cache",
"sizeGb": 5
}
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
image: 'node:22',
timeoutMs: 600000,
env: {NODE_ENV: 'production', API_KEY: 'secret'},
volumes: {'/workspace': 'my_packages', '/cache': {name: 'build_cache', sizeGb: 5}}
})
};
fetch('https://api.example.com/api/v1/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.example.com/api/v1/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' => 'node:22',
'timeoutMs' => 600000,
'env' => [
'NODE_ENV' => 'production',
'API_KEY' => 'secret'
],
'volumes' => [
'/workspace' => 'my_packages',
'/cache' => [
'name' => 'build_cache',
'sizeGb' => 5
]
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/sandboxes"
payload := strings.NewReader("{\n \"image\": \"node:22\",\n \"timeoutMs\": 600000,\n \"env\": {\n \"NODE_ENV\": \"production\",\n \"API_KEY\": \"secret\"\n },\n \"volumes\": {\n \"/workspace\": \"my_packages\",\n \"/cache\": {\n \"name\": \"build_cache\",\n \"sizeGb\": 5\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/sandboxes")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"node:22\",\n \"timeoutMs\": 600000,\n \"env\": {\n \"NODE_ENV\": \"production\",\n \"API_KEY\": \"secret\"\n },\n \"volumes\": {\n \"/workspace\": \"my_packages\",\n \"/cache\": {\n \"name\": \"build_cache\",\n \"sizeGb\": 5\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/sandboxes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"node:22\",\n \"timeoutMs\": 600000,\n \"env\": {\n \"NODE_ENV\": \"production\",\n \"API_KEY\": \"secret\"\n },\n \"volumes\": {\n \"/workspace\": \"my_packages\",\n \"/cache\": {\n \"name\": \"build_cache\",\n \"sizeGb\": 5\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"sandbox": {
"id": "e7847229c547d8",
"name": "sandbox-node-1",
"state": "started",
"region": "iad",
"image": "node:22",
"createdAt": "2023-12-01T00:00:00Z",
"stopAt": "2023-12-01T01:00:00Z",
"publicAccessUrlTemplate": "{{PORT}}-m_01h9z60rm0ex1rc4x-sandbox-shared-app-fly.apps.simplesandbox.dev"
}
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}API Reference
Post apiv1sandboxes
POST
/
api
/
v1
/
sandboxes
cURL
curl --request POST \
--url https://api.example.com/api/v1/sandboxes \
--header 'Content-Type: application/json' \
--data '
{
"image": "node:22",
"timeoutMs": 600000,
"env": {
"NODE_ENV": "production",
"API_KEY": "secret"
},
"volumes": {
"/workspace": "my_packages",
"/cache": {
"name": "build_cache",
"sizeGb": 5
}
}
}
'import requests
url = "https://api.example.com/api/v1/sandboxes"
payload = {
"image": "node:22",
"timeoutMs": 600000,
"env": {
"NODE_ENV": "production",
"API_KEY": "secret"
},
"volumes": {
"/workspace": "my_packages",
"/cache": {
"name": "build_cache",
"sizeGb": 5
}
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
image: 'node:22',
timeoutMs: 600000,
env: {NODE_ENV: 'production', API_KEY: 'secret'},
volumes: {'/workspace': 'my_packages', '/cache': {name: 'build_cache', sizeGb: 5}}
})
};
fetch('https://api.example.com/api/v1/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.example.com/api/v1/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' => 'node:22',
'timeoutMs' => 600000,
'env' => [
'NODE_ENV' => 'production',
'API_KEY' => 'secret'
],
'volumes' => [
'/workspace' => 'my_packages',
'/cache' => [
'name' => 'build_cache',
'sizeGb' => 5
]
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/sandboxes"
payload := strings.NewReader("{\n \"image\": \"node:22\",\n \"timeoutMs\": 600000,\n \"env\": {\n \"NODE_ENV\": \"production\",\n \"API_KEY\": \"secret\"\n },\n \"volumes\": {\n \"/workspace\": \"my_packages\",\n \"/cache\": {\n \"name\": \"build_cache\",\n \"sizeGb\": 5\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/sandboxes")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"node:22\",\n \"timeoutMs\": 600000,\n \"env\": {\n \"NODE_ENV\": \"production\",\n \"API_KEY\": \"secret\"\n },\n \"volumes\": {\n \"/workspace\": \"my_packages\",\n \"/cache\": {\n \"name\": \"build_cache\",\n \"sizeGb\": 5\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/sandboxes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"node:22\",\n \"timeoutMs\": 600000,\n \"env\": {\n \"NODE_ENV\": \"production\",\n \"API_KEY\": \"secret\"\n },\n \"volumes\": {\n \"/workspace\": \"my_packages\",\n \"/cache\": {\n \"name\": \"build_cache\",\n \"sizeGb\": 5\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"sandbox": {
"id": "e7847229c547d8",
"name": "sandbox-node-1",
"state": "started",
"region": "iad",
"image": "node:22",
"createdAt": "2023-12-01T00:00:00Z",
"stopAt": "2023-12-01T01:00:00Z",
"publicAccessUrlTemplate": "{{PORT}}-m_01h9z60rm0ex1rc4x-sandbox-shared-app-fly.apps.simplesandbox.dev"
}
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}{
"code": 422,
"message": "Validation failed: Name has already been taken",
"details": null
}Body
application/json
Docker image to run inside the shared Fly app
Example:
"node:22"
Optional timeout in milliseconds for the sandbox. Defaults to 10 minutes (600000ms). Maximum 1 hour (3600000ms) from creation for FREE users.
Required range:
x >= 0Example:
600000
Environment variables to set in the sandbox. These will be available to all commands executed in the sandbox.
Show child attributes
Show child attributes
Example:
{
"NODE_ENV": "production",
"API_KEY": "secret"
}
Mount volumes by name. Creates if missing, reuses if exists. Key is mount path, value is volume name or config. Volume names must contain only lowercase alphanumeric characters and underscores (max 30 chars).
Show child attributes
Show child attributes
Example:
{
"/workspace": "my_packages",
"/cache": { "name": "build_cache", "sizeGb": 5 }
}
Response
Sandbox created
Show child attributes
Show child attributes
⌘I