Run a command

Preview. Run one command in a running sandbox, and answer its exit code and its output.

With stream, the answer is NDJSON: stdout and stderr events with text as the command writes it, then one exit or error event.

POST
/sandboxes/{sandbox_id}/exec

Authorization

headerAuthorizationBearer <token>

Your Munito API key.

Path Parameters

sandbox_id*string

The id of the sandbox.

Request Body

application/json
  1. body

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

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 1800, 60 by default.

stdin?|

Text for standard input, which then closes. Without it, standard input is empty.

stream?boolean

Answer NDJSON events as the command writes, instead of one result at its end.

Defaultfalse

Response Body

One result, or with stream the NDJSON events.

  1. response
exit_code*integer

The exit code. A command that a signal stopped has 128 plus the signal.

stdout*string

Standard output as UTF-8 text, at most 1048576 bytes.

stderr*string

Standard error as UTF-8 text, at most 1048576 bytes.

duration_ms*integer

How long the command ran.

timed_out*boolean

The command ran past its timeout and was stopped.

truncated*boolean

A stream passed its limit, and the rest is left out.

curl -X POST 'https://api.munito.ai/sandboxes/v1/sandboxes/string/exec' \
  -H 'Content-Type: application/json' \
  -d '{
  "command": "string"
}'
Example Response
{
  "exit_code": 0,
  "stdout": "string",
  "stderr": "string",
  "duration_ms": 0,
  "timed_out": true,
  "truncated": true
}