v48

latestOpenAPI 3.0.0raw.githubusercontent.com2025-12-0297180624.8 KB
Run Code

Run code on the box

Executes code inside the specified box. Supports multiple languages (bash, Python, TypeScript) and allows you to configure environment variables, arguments, working directory, and timeouts.

post/boxes/{boxId}/run-code

Path parameters

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

Box ID

Request body

codestring required

The code to run

language'bash' | 'python' | 'typescript'

The language of the code.

envsobject

The environment variables to run the code

argvstring[]

The arguments to run the code. For example, if you want to run "python index.py --help", you should pass ["--help"] as arguments.

workingDirstring

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

timeoutstring

The timeout of the code execution. If the code execution times out, the exit code will be 124.

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

Example request

{
  "code": "print('Hello, World!')\nprint(2 + 3)",
  "language": "python",
  "envs": {
    "PYTHONPATH": "/usr/lib/python",
    "DEBUG": "true"
  },
  "argv": [
    "--help"
  ],
  "workingDir": "/home/user/scripts",
  "timeout": "30s"
}

Response

exitCodenumber required

The exit code of the code

stdoutstring required

The stdout of the code

stderrstring required

The stderr of the code

Example response

{
  "stdout": "Hello, World!\n5"
}