Run a command and wait for it to finish
Runs a command to completion and returns its output in a single
response, retained up to a server-side cap (see truncated). For live
or unbounded output use POST /exec/stream (Server-Sent Events) or
GET /exec/connect (WebSocket). A non-zero exit code is returned in
the body, not as an HTTP error. The sandbox must be running; a
paused sandbox returns 503. Activate it first with
POST /sandboxes/{sandbox_id}/activate (the SDKs do this
automatically).
curl --request POST \
--url https://sandbox.superserve.ai/exec \
--header 'Content-Type: application/json' \
--header 'X-Access-Token: <api-key>' \
--data '
{
"command": "<string>",
"args": [
"<string>"
],
"env": {},
"working_dir": "<string>",
"timeout_s": 30
}
'import requests
url = "https://sandbox.superserve.ai/exec"
payload = {
"command": "<string>",
"args": ["<string>"],
"env": {},
"working_dir": "<string>",
"timeout_s": 30
}
headers = {
"X-Access-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Access-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
command: '<string>',
args: ['<string>'],
env: {},
working_dir: '<string>',
timeout_s: 30
})
};
fetch('https://sandbox.superserve.ai/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://sandbox.superserve.ai/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' => '<string>',
'args' => [
'<string>'
],
'env' => [
],
'working_dir' => '<string>',
'timeout_s' => 30
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Access-Token: <api-key>"
],
]);
$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://sandbox.superserve.ai/exec"
payload := strings.NewReader("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"timeout_s\": 30\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Access-Token", "<api-key>")
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://sandbox.superserve.ai/exec")
.header("X-Access-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"timeout_s\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.superserve.ai/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Access-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"timeout_s\": 30\n}"
response = http.request(request)
puts response.read_body{
"stdout": "<string>",
"stderr": "<string>",
"exit_code": 123,
"truncated": true
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Authorizations
Per-sandbox token returned by create, resume, and activate. Grants access to a single sandbox's files and commands. Distinct from the team X-API-Key.
Body
Command to execute. Wrapped in /bin/sh -c unless args is provided.
1If provided, command is used as the binary and args as arguments (no shell wrapping).
Environment variables for the command.
Show child attributes
Show child attributes
Working directory (default /home/user).
Timeout in seconds.
Response
The command finished; output and exit code.
Output of a command run to completion via POST /exec.
Standard output; see truncated.
Standard error; see truncated.
Process exit code. A non-zero value is returned, not raised.
Present and true when combined stdout/stderr exceeded the server-side retention cap (currently 8 MiB) and the tail was dropped; a notice explaining the cut is also appended to stderr. Use POST /exec/stream for unbounded output.
curl --request POST \
--url https://sandbox.superserve.ai/exec \
--header 'Content-Type: application/json' \
--header 'X-Access-Token: <api-key>' \
--data '
{
"command": "<string>",
"args": [
"<string>"
],
"env": {},
"working_dir": "<string>",
"timeout_s": 30
}
'import requests
url = "https://sandbox.superserve.ai/exec"
payload = {
"command": "<string>",
"args": ["<string>"],
"env": {},
"working_dir": "<string>",
"timeout_s": 30
}
headers = {
"X-Access-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Access-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
command: '<string>',
args: ['<string>'],
env: {},
working_dir: '<string>',
timeout_s: 30
})
};
fetch('https://sandbox.superserve.ai/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://sandbox.superserve.ai/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' => '<string>',
'args' => [
'<string>'
],
'env' => [
],
'working_dir' => '<string>',
'timeout_s' => 30
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Access-Token: <api-key>"
],
]);
$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://sandbox.superserve.ai/exec"
payload := strings.NewReader("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"timeout_s\": 30\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Access-Token", "<api-key>")
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://sandbox.superserve.ai/exec")
.header("X-Access-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"timeout_s\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.superserve.ai/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Access-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"timeout_s\": 30\n}"
response = http.request(request)
puts response.read_body{
"stdout": "<string>",
"stderr": "<string>",
"exit_code": 123,
"truncated": true
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}