Run Code in a Sandbox Session
sessionRun a command or code in an open E2B sandbox session (started by use with action create_session, which returns a session_id). Pass session_id plus either command (a shell command) or code (+ optional language: python/javascript/bash). Returns stdout/stderr/exit_code (or the code result). The sandbox stays alive — and billed per second of uptime — until you close it; re-running reuses the SAME box, so filesystem + process state persist between calls. ALWAYS close when done.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"session_id": "<session_id>"
},
"name": "session"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Code to execute (alternative to `command`). | |
| command | No | Shell command to run in the sandbox. | |
| language | No | Language for `code`: python (default), javascript, or bash. | |
| session_id | Yes | The session_id returned by create_session. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | True when the call succeeded. | |
| error | No | Error code/message when ok=false. | |
| result | No | Structured result, when the runtime returns one. | |
| stderr | No | Captured standard error. | |
| stdout | No | Captured standard output. | |
| exit_code | No | Process exit code. |