Run a command
curl --request POST \
--url https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "python3 --version && echo $MODE"
}
'import requests
url = "https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec"
payload = { "command": "python3 --version && echo $MODE" }
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({command: 'python3 --version && echo $MODE'})
};
fetch('https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec', 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://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec",
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([
'command' => 'python3 --version && echo $MODE'
]),
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://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec"
payload := strings.NewReader("{\n \"command\": \"python3 --version && echo $MODE\"\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://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"python3 --version && echo $MODE\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec")
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 \"command\": \"python3 --version && echo $MODE\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"finished": true,
"exit_code": 0,
"stdout": "Python 3.12.3\ntest\n",
"stderr": "",
"truncated": false,
"seconds": 0.41
}
}{
"error": {
"code": "UNAUTHENTICATED",
"message": "Missing or invalid Authorization header. Use: Authorization: Bearer <token>"
}
}{
"message": "Sandbox not found."
}{
"message": "Start the sandbox first."
}{
"message": "The command field is required.",
"errors": {
"command": [
"The command field is required."
]
}
}{
"message": "The sandbox did not answer. If it was just started, try again in a few seconds."
}Sandboxes
Run a Command
Runs a shell command in a running sandbox and returns what it printed. Linux runs it with sh -c, Windows with PowerShell.
The call waits up to 60 seconds. A command still running then goes on inside the sandbox, and the answer comes back with finished: false and exit_code: null. Start longer jobs in the background (for example with nohup ... &) and check on them with later commands.
stdout and stderr are each cut at 64 KB, and truncated says when. The sandbox’s environment variables are loaded first. A command counts as activity, so it resets the auto-stop timer. Every command is in the sandbox’s logs.
Rate limit: 120 a minute, counted apart from the rest of the API, see Limits.
POST
/
sandboxes
/
{sandbox}
/
exec
Run a command
curl --request POST \
--url https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "python3 --version && echo $MODE"
}
'import requests
url = "https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec"
payload = { "command": "python3 --version && echo $MODE" }
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({command: 'python3 --version && echo $MODE'})
};
fetch('https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec', 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://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec",
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([
'command' => 'python3 --version && echo $MODE'
]),
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://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec"
payload := strings.NewReader("{\n \"command\": \"python3 --version && echo $MODE\"\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://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"python3 --version && echo $MODE\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.cloudblast.io/api/v2/sandboxes/{sandbox}/exec")
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 \"command\": \"python3 --version && echo $MODE\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"finished": true,
"exit_code": 0,
"stdout": "Python 3.12.3\ntest\n",
"stderr": "",
"truncated": false,
"seconds": 0.41
}
}{
"error": {
"code": "UNAUTHENTICATED",
"message": "Missing or invalid Authorization header. Use: Authorization: Bearer <token>"
}
}{
"message": "Sandbox not found."
}{
"message": "Start the sandbox first."
}{
"message": "The command field is required.",
"errors": {
"command": [
"The command field is required."
]
}
}{
"message": "The sandbox did not answer. If it was just started, try again in a few seconds."
}Authorizations
Path Parameters
Body
application/json