v48

latestOpenAPI 3.0.0raw.githubusercontent.com2025-12-0297180624.8 KB
Command

Exec command

Execute a command on a running box. This endpoint allows you to send commands to the box and receive the output

post/boxes/{boxId}/commands

Path parameters

boxIdstring required
Example:c9bdc193-b54b-4ddb-a035-5ac0c598d32d

Box ID

Request body

commandstring required

The command to run

envsobject

The environment variables to run the command

workingDirstring

The working directory of the command. It not provided, the command will be run in the box.config.workingDir directory.

timeoutstring

The timeout of the command. If the command times out, the exit code will be 124. For example: 'timeout 5s sleep 10s' will result in exit code 124.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: "500ms", "30s", "5m", "1h" Default: 30s

Example request

{
  "command": "ls -la",
  "envs": {
    "PATH": "/usr/bin:/bin",
    "NODE_ENV": "production"
  },
  "workingDir": "/home/user/projects",
  "timeout": "30s"
}

Response

exitCodenumber required

The exit code of the command

stdoutstring required

The standard output of the command

stderrstring required

The standard error output of the command

Example response

{
  "stdout": "total 16\ndrwxr-xr-x  4 user user 4096 Jan 15 10:30 .\ndrwxr-xr-x  3 user user 4096 Jan 15 10:25 .."
}