Skip to content

Exec

This runs a command in the running sandbox web:

Terminal window
curl --unix-socket /var/lib/shard/shard.sock -X POST -H 'Content-Type: application/json' -d '{"command":["/bin/echo","hi"]}' http://localhost/v0/sandboxes/web/exec

The daemon answers 201 with the Exec. Routes with {exec} in the path use its exec field as the id. This one waits for the command to end:

Terminal window
curl --unix-socket /var/lib/shard/shard.sock 'http://localhost/v0/sandboxes/web/exec/<exec>?wait=true'

Each route answers an error with the Error body, unless its responses say otherwise.

POST /v0/sandboxes/{id}/exec · scope exec

Parameters

Name In Type Required Description
id path string yes The sandbox id or name.

Request body

ExecRequest as application/json, required.

Responses

Status Body
201 Exec as application/json

GET /v0/sandboxes/{id}/exec · scope exec

Parameters

Name In Type Required Description
id path string yes The sandbox id or name.
limit query integer (int64) no The most items on a page; absent returns the whole list. At least 1.
cursor query string no The next value of the previous page; this page starts after it.

Responses

Status Body
200 ExecsResponse as application/json

GET /v0/sandboxes/{id}/exec/{exec} · scope exec

Parameters

Name In Type Required Description
id path string yes The sandbox id or name.
exec path string yes The exec id.
wait query boolean no Block until the exec ends.

Responses

Status Body Description
101 WebSocket A WebSocket attach. Each binary message leads with its stream byte: 0 stdin and 4 stdin closed from the client; 1 stdout, 2 stderr, 3 the ExitMessage and 5 a FailureMessage from the daemon.
200 Exec as application/json The exec as it stands, or with wait once it ends.

WebSocket messages

Stream byte Payload
3 ExitMessage
5 FailureMessage

POST /v0/sandboxes/{id}/exec/{exec}/kill · scope exec

Parameters

Name In Type Required Description
id path string yes The sandbox id or name.
exec path string yes The exec id.

Request body

KillRequest as application/json, optional.

Responses

Status Body
204 none

DELETE /v0/sandboxes/{id}/exec/{exec} · scope exec

Parameters

Name In Type Required Description
id path string yes The sandbox id or name.
exec path string yes The exec id.

Responses

Status Body
204 none

POST /v0/sandboxes/{id}/exec/{exec}/resize · scope exec

Parameters

Name In Type Required Description
id path string yes The sandbox id or name.
exec path string yes The exec id.

Request body

TerminalSize as application/json, optional.

Responses

Status Body
204 none
Field Type Required Description
command array of string yes
exec string yes
exit_status ExitStatus or null yes
exited_at string (date-time) or null yes
lost_bytes integer (int64) yes
sandbox string yes
started_at string (date-time) yes
state string yes One of running, exited.
truncated boolean yes
Field Type Required Description
attach boolean no
command array of string yes At least 1 item.
env array of string no
size TerminalSize no
stdin boolean no
tty boolean no
user string no
workdir string no
Field Type Required
execs array of Exec yes
next string or null yes
Field Type Required Description
code integer (int64) yes The exit code, or the code a command that never started ends with.
error string no Why the command never started; absent when it started.
lost_bytes integer (int64) no The output bytes the buffer dropped before this client read them; absent when it dropped none.
signal integer (int64) yes The signal that ended the command, or 0.
Field Type Required Description
code string yes One of the codes of ErrorObject.code.
message string yes
Field Type Required
error FailureError yes
Field Type Required Description
signal string no TERM or KILL, in capitals; absent or empty is TERM.
Field Type Required Description
cols integer (int32) no From 0 to 65535.
rows integer (int32) no From 0 to 65535.