Skip to content
中文

Run a command in the sandbox

Call Create sandbox first and replace sbx_123 with its returned sandboxID.

POST/sandbox/v1/sandboxes/{sandbox_id}/commands● Supported

Request parameters

  • sandbox_idstringrequired

    path: Sandbox ID returned by sandboxes.create or sandboxes.list.

  • cmdstringrequired

    Shell command to execute, for example echo hi.

  • backgroundbooleanoptional
    default false

    When true, return 202 with the pid as soon as the process starts; it keeps running after the request ends. Read its status and output with GET /sandbox/v1/sandboxes/{sandbox_id}/commands/{pid}, stop it with DELETE. Same idea as E2B background commands.

  • cwdstringoptional

    Working directory; omitted uses the sandbox user's home directory.

  • envsobjectoptional

    Environment overrides for this command; omitted uses the sandbox environment.

  • timeoutMsintegeroptional
    default 600000

    Execution timeout in milliseconds, from 1 to 3600000 (1 hour); defaults to 600000 (10 minutes). In background mode this limits process runtime; expiry records exit code 124.

  • progressTimeoutMsintegeroptional

    Foreground commands only, off by default: end this command once it goes this many milliseconds (1000 to 3600000) without writing a single byte to stdout or stderr, and answer COMMAND_NO_PROGRESS (504) with the output received so far and lastOutputAt. The sandbox itself keeps running, so decide afterwards whether to read what it produced or stop it with DELETE. A slow command that keeps producing output is never ended by it; if the program buffers its output, turn buffering off first, for example PYTHONUNBUFFERED=1 or stdbuf -oL. Passing it together with background true is refused with INVALID_PARAMS.

Returns

200

Errors follow the E2B format — see error codes

Request

curl
# Call Create sandbox first and replace sbx_123 with its returned sandboxID.
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/commands \
  -H "X-API-Key: $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cmd":"echo hello","timeoutMs":10000}'
Python
# Call Create sandbox first and replace sbx_123 with its returned sandboxID.
import requests

api_key = "$PRAXIS_API_KEY"

# Call /sandbox/v1 directly over HTTP.
resp = requests.post(
    "https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/commands",
    headers={"X-API-Key": api_key},
    json={"cmd": "echo hello", "timeoutMs": 10000},
)
print(resp.status_code, resp.text)
TypeScript
// Call Create sandbox first and replace sbx_123 with its returned sandboxID.
const apiKey = "$PRAXIS_API_KEY";

// Call /sandbox/v1 directly over HTTP.
const resp = await fetch(`https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/commands`, {
  method: "POST",
  headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify({ cmd: "echo hello", timeoutMs: 10000 }),
});
console.log(resp.status, await resp.text());

Response 200

{
  "stdout": "hello\n",
  "stderr": "",
  "exitCode": 0
}

Response

HTTP 200

Operation completed

application/json

Name Type Description
stdout string Captured standard output as UTF-8 text.
stderr string Captured standard error as UTF-8 text.
exitCode integer Process exit code; zero means success. Nonzero exits also return this result.