Run a command in a running sandbox
POST
/sandboxes/{id}/exec
const url = 'https://api.global.stillbox.example/v1/sandboxes/ws-7k2m9q4x8w3z5r6t/exec';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"command":["example"],"env":{"additionalProperty":"example"},"cwd":"example","user":"example","stdin":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.global.stillbox.example/v1/sandboxes/ws-7k2m9q4x8w3z5r6t/exec \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "command": [ "example" ], "env": { "additionalProperty": "example" }, "cwd": "example", "user": "example", "stdin": "example" }'With Accept: text/event-stream, output streams as server-sent events while the command runs:
stdout and stderr events carry base64 data, and a final exit event carries the exit_code
(or error if the command could not run). Otherwise the call waits for the command to finish and
returns its output as text. Output is limited to 16 MB per stream without streaming.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”id
required
string
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
command
required
Array<string>
env
object
key
additional properties
string
cwd
string
user
User name or uid[:gid] inside the sandbox. Defaults to the image’s user.
string
stdin
Text passed to the command’s standard input (up to 1 MB).
string
Example generated
{ "command": [ "example" ], "env": { "additionalProperty": "example" }, "cwd": "example", "user": "example", "stdin": "example"}Responses
Section titled “Responses”The command’s output
object
exit_code
required
integer
stdout
required
string
stderr
required
string
Example generated
{ "exit_code": 1, "stdout": "example", "stderr": "example"}Server-sent events (see the description above)
string
The request is invalid
Media typeapplication/json
object
code
required
string
message
required
string
Example
{ "code": "not_found"}The API key is missing or invalid
Media typeapplication/json
object
code
required
string
message
required
string
Example
{ "code": "not_found"}No such sandbox in your organization (or no such file)
Media typeapplication/json
object
code
required
string
message
required
string
Example
{ "code": "not_found"}The sandbox isn’t running, or its server is unreachable right now
Media typeapplication/json
object
code
required
string
message
required
string
Example
{ "code": "not_found"}