Process
Process endpoints let you execute one-shot commands inside a running sandbox.
Execute a command
Section titled “Execute a command”Run a shell command and wait for the result. The command runs inside /bin/sh -c.
from leap0 import Leap0Client
client = Leap0Client()sandbox = client.sandboxes.create()result = sandbox.process.execute( command="echo Hello from Leap0", cwd="/home/user", timeout=30,)
print(result.exit_code)print(result.stdout)print(result.stderr)const apiUrl = "https://api.leap0.dev"const apiKey = "<your-api-key>"const sandboxId = "<sandbox_id>"
const res = await fetch(`${apiUrl}/v1/sandbox/${sandboxId}/process/execute`, {method: "POST",headers: { authorization: apiKey, "Content-Type": "application/json",},body: JSON.stringify({ command: "echo Hello from Leap0", cwd: "/home/user", timeout: 30,}),})
const data = await res.json()console.log(data.exit_code) // 0console.log(data.stdout) // Hello from Leap0console.log(data.stderr) // ""