Skip to main content
POST
Run a command

Authorizations

Authorization
string
header
required

An API key that starts with vms_. Make one in Settings > API keys.

Path Parameters

id
string
required
Example:

"sbx_06d8k3m7q2v9x4b1n5c0e8f2ja"

Body

application/json
command
required

A shell command as one string, which runs with bash -lc, or the program and its arguments as a list.

Minimum string length: 1
Example:

"npm test"

cwd
string

The working folder. The default is the home folder of root.

Required string length: 1 - 4096
Pattern: ^\/
Example:

"/home/user/app"

env
object

Environment variables to add for this command.

timeoutSeconds
integer | null

The time limit in seconds. At the limit, the command gets SIGKILL. Leave it out or send null for no time limit.

Required range: 0 < x <= 9007199254740991
stdin
boolean

Keep stdin open, so that you can send input with POST /v1/sandboxes/{id}/commands/{commandId}/stdin.

detached
boolean

Answer 201 with the command at once. The command runs after you disconnect.

Response

The output of the command. Each line is one JSON event: started, then stdout and stderr, then exit. Each event has a seq that starts at 0. When no event comes for 15 seconds, the stream sends an empty line. Skip empty lines.

type
string
required
Allowed value: "started"
seq
integer
required
Required range: 0 <= x <= 9007199254740991
at
string<date-time>
required
Pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
commandId
string
required

The ID of a record, such as a slot or a command.

Pattern: ^[a-z0-9_]{1,64}$
pid
integer
required
Required range: x <= 9007199254740991