Execute code
Run code in a persistent REPL session and wait for the full result. If `context_id` is omitted a new session is created automatically. Supported languages: `python`, `typescript`.
POST
/executeRun code in a persistent REPL session and wait for the full result.
If context_id is omitted a new session is created automatically.
Supported languages: python, typescript.
Authorization
BearerAuth AuthorizationBearer <token>
API key passed as a Bearer token.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
code*string
Source code to execute.
context_id?string
Link execution to an existing context. Auto-generated if omitted.
language?string
Language runtime to use.
Default
"python"Value in
"python" | "py" | "python3" | "typescript" | "ts" | "javascript" | "js" | "bun" | "node"env_vars?
Environment variables for the execution.
timeout_ms?integer
Execution timeout in milliseconds.
Default
30000Response Body
application/json
application/json
application/json
curl -X POST "https://<sandbox_id>.sandbox.leap0.dev/execute" \ -H "Content-Type: application/json" \ -d '{ "code": "print(\'hello\')" }'{ "context_id": "string", "items": [ { "is_primary": true, "text": "string", "html": "string", "markdown": "string", "svg": "string", "png": "string", "jpeg": "string", "pdf": "string", "latex": "string", "json": {}, "javascript": "string", "extra": {} } ], "logs": { "stdout": [ "string" ], "stderr": [ "string" ] }, "error": { "name": "NameError", "value": "name 'x' is not defined", "traceback": "string" }, "execution_count": 0}{ "message": "Invalid request", "errors": [ { "field": "string", "error": "string" } ]}{ "context_id": "string", "items": [ { "is_primary": true, "text": "string", "html": "string", "markdown": "string", "svg": "string", "png": "string", "jpeg": "string", "pdf": "string", "latex": "string", "json": {}, "javascript": "string", "extra": {} } ], "logs": { "stdout": [ "string" ], "stderr": [ "string" ] }, "error": { "name": "NameError", "value": "name 'x' is not defined", "traceback": "string" }, "execution_count": 0}
