Skip to main content
POST
/
api
/
v1
/
sandbox
/
sessions
/
{session_id}
/
code
Typescript (SDK)
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.sandbox.runCode({
    sessionId: "demo-python-20260316",
    codeRequest: {
      sessionId: "demo-python-20260316",
      sessionToken: "sandbox_test_20260316_4f9c2b1a",
      code: "from pathlib import Path; Path('live_check.txt').write_text('ok'); print('code-ran')",
      cwd: null,
      env: {

      },
    },
  });

  console.log(result);
}

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

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

Path Parameters

session_id
string
required

Body

application/json
session_id
string
required
session_token
string
required
code
string
required
runtime
string
default:python
cwd
string | null
env
Env · object
timeout_seconds
integer
default:60

Response

Successful Response

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