Saltar al contenido principal
POST
/
api
/
v1
/
sandbox
/
sessions
/
{session_id}
/
code
Python (SDK)
from openapi import SDK


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

    res = sdk.sandbox.run_code(session_id_param="demo-python-20260316", session_id="demo-python-20260316", code="from pathlib import Path; Path('live_check.txt').write_text('ok'); print('code-ran')", session_token="sandbox_test_20260316_4f9c2b1a", runtime="python", cwd=None, env={

    }, timeout_seconds=60)

    # Handle response
    print(res)
{
  "session_id": "demo-python-20260316",
  "runtime": "python",
  "cwd": "/workspace",
  "stdout": "code-ran\n",
  "stderr": "",
  "exit_code": 0,
  "files_changed": [
    "live_check.txt"
  ]
}

Autorizaciones

Authorization
string
header
requerido

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>.

Parámetros de ruta

session_id
string
requerido

Cuerpo

application/json
session_id
string
requerido
code
string
requerido
session_token
string | null
runtime
enum<string>
predeterminado:python
Opciones disponibles:
python,
python3,
javascript,
node,
go,
bash,
shell,
sh
cwd
string | null
env
Env · object
timeout_seconds
integer
predeterminado:60

Respuesta

Respuesta exitosa

session_id
string
requerido
runtime
enum<string>
requerido
Opciones disponibles:
python,
python3,
javascript,
node,
go,
bash,
shell,
sh
cwd
string
requerido
exit_code
integer
requerido
stdout
string
predeterminado:""
stderr
string
predeterminado:""
files_changed
string[]