Start a background command

Preview. Start a command that keeps running after this answer, and give it an id.

A command of POST /sandboxes/{sandbox_id}/exec ends when its request ends. A background command runs until it exits, until its timeout, until you signal it, or until its sandbox stops.

POST
/sandboxes/{sandbox_id}/commands

Authorization

headerAuthorizationBearer <token>

Your Munito API key.

Path Parameters

sandbox_id*string

The id of the sandbox.

Request Body

application/json
  1. body

A command that answers at once and runs on in the sandbox.

command*|array<string>

A string runs in bash -lc. A list is the argument vector itself.

cwd?|

The working directory, /workspace by default.

env?

More environment variables for this command.

timeout?|

Seconds until the command is stopped: from 1 to 86400, 3600 by default. Its sandbox still ends it at its own timeout.

stdin?|

Text for standard input, which then closes.

Response Body

The command, running, with its id and no output yet.

application/json
  1. response
id*string
command*array<string>

The argument vector that runs.

cwd*string
status*string

running, then exited with an exit code, or failed when the sandbox lost the command.

Value in"running""exited""failed"
started_at*number

Unix seconds.

ended_at?|

Unix seconds, or null while the command runs.

exit_code?|

The exit code, or null while it runs. A command that a signal stopped has 128 plus the signal.

timed_out?boolean
Defaultfalse
stdout?string

Standard output after stdout of the request. A list of commands leaves it out.

Default""
stderr?string

Standard error after stderr of the request. A list of commands leaves it out.

Default""
stdout_bytes?integer

The bytes of standard output so far. Send it as stdout to read only what follows.

Default0
stderr_bytes?integer

The bytes of standard error so far. Send it as stderr to read only what follows.

Default0
truncated?boolean

Each stream keeps 1048576 bytes. The command wrote more, and the rest is left out. Write the output to a file for more.

Defaultfalse
curl -X POST 'https://api.munito.ai/sandboxes/v1/sandboxes/string/commands' \
  -H 'Content-Type: application/json' \
  -d '{
  "command": "string"
}'
Example Response
{
  "id": "string",
  "command": [
    "string"
  ],
  "cwd": "string",
  "status": "running",
  "started_at": 0,
  "ended_at": 0,
  "exit_code": 0,
  "timed_out": false,
  "stdout": "",
  "stderr": "",
  "stdout_bytes": 0,
  "stderr_bytes": 0,
  "truncated": false
}