Skip to main content
POST
/
api
/
v1
/
sandbox
/
sessions
/
{session_id}
/
commands
Python (SDK)
from mka1 import SDK


with SDK(
    bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:

    res = sdk.sandbox.run_command(session_id_param="demo-python-20260316", session_id="demo-python-20260316", command="python3", session_token="sandbox_test_20260316_4f9c2b1a", args=[
        "-c",
        "import math; print(math.sqrt(144))",
    ], cwd=None, env={

    }, timeout_seconds=60)

    # Handle response
    print(res)
{
  "session_id": "demo-python-20260316",
  "command": "python3",
  "args": [
    "-c",
    "import math; print(math.sqrt(144))"
  ],
  "cwd": "/workspace",
  "stdout": "12.0\n",
  "stderr": "",
  "exit_code": 0,
  "files_changed": []
}

Authorizations

Authorization
string
header
required

Gateway auth: send Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, you can also send X-On-Behalf-Of: <external-user-id>.

Headers

X-On-Behalf-Of
string

Optional external end-user identifier forwarded by the API gateway.

Path Parameters

session_id
string
required

Body

application/json
session_id
string
required
command
string
required
session_token
string | null
command_request_id
string | null
args
string[]
cwd
string | null
env
Env · object
timeout_seconds
integer
default:60

Response

Successful Response

session_id
string
required
command
string
required
cwd
string
required
exit_code
integer
required
args
string[]
stdout
string
default:""
stderr
string
default:""
files_changed
string[]