Skip to main content
POST
Execute Python
Runs Python code on the computer and returns its output. Each call is a fresh interpreter, so nothing carries over between requests. On Linux the code runs with python3 -c, HOME=/root, DISPLAY=:99, and PATH=/usr/local/bin:/usr/bin:/bin. On Windows, the code is written to a temporary file and run with C:\Python312\python.exe from the user’s Desktop folder. The response carries stdout, stderr, exit_code, and output instead of the fields listed under Response, plus error when the code could not run. Code that runs out of time returns 200 with exit_code: 124 and error: "timeout".

Path parameters

string
required
Computer ID (UUID).

Body parameters

string
required
Python code to run. Missing, empty, or not a string returns 400.
integer
default:"10"
How long the code may run, in seconds. Optional, and always clamped to 1-300: a larger value silently becomes 300, and 0 or a non-numeric value becomes 10. Out-of-range values are never rejected.
exec takes no ?screen= parameter. Unlike the pointer and keyboard actions, sending one here is silently ignored rather than rejected. The code always runs against the computer’s default display.

Response

boolean
true only when the interpreter exited zero. Code that raises returns 200 with success: false, not an error status.
string
Always exec.
string
Combined stdout and stderr, in that order, joined by a newline when both are non-empty. An uncaught exception’s traceback arrives here, and it is the only place it appears.
boolean
Always false. Code killed by the timeout also returns false, so this field carries no information. Infer a timeout from success: false with truncated output instead.
string | null
Always null on a 200, including when the code raises. Read output for the traceback.
string | null
Always null on a 200. It never carries a Python exception class. Parse output if you need the exception name.

Example

Successful response

Response when the code raises

Still a 200. The exception is in output; error and error_type stay null.
For shell commands, use Execute bash instead.

Errors

Code that raises is not an error status: it is a 200 with success: false. Every failure raised after the request leaves the API layer carries a request_id. Quote it in support requests. When the computer agent itself answered non-2xx, the body additionally carries upstream_status.

Authorizations

Authorization
string
header
required

API key authentication. Get your key at orgo.ai/workspaces

Path Parameters

id
string
required

Computer ID

Body

application/json
code
string
required

Python code to execute

timeout
integer
default:10

How long the code may run, in seconds. Always clamped to 1-300: a larger value becomes 300, and 0 or a non-numeric value becomes 10. Out-of-range values are never rejected.

Required range: 1 <= x <= 300

Response

The code ran. Code that raises is still a 200, with success: false and the traceback in output.

success
boolean

true only when the interpreter exited zero. Code that raises returns 200 with success: false.

action
enum<string>
Available options:
exec
output
string

Combined stdout and stderr. An uncaught exception's traceback arrives here.

timeout
enum<boolean>

Always false, even when the code was killed by the timeout. Infer a timeout from success: false with truncated output.

Available options:
false
error
null

Always null on a 200, including when the code raises.

error_type
null

Always null on a 200. It never carries a Python exception class.