Skip to main content
POST
/
v1
/
sandboxes
/
{id}
/
exec
curl -N -X POST https://api.podflare.ai/v1/sandboxes/$SID/exec \
  -H 'content-type: application/json' \
  -d '{"code": "print(6*7)"}'
{"type":"stdout","data":"42","seq":0,"ts":1776510028036}
{"type":"exit","data":0,"seq":1,"ts":1776510028037}

Documentation Index

Fetch the complete documentation index at: https://docs.podflare.ai/llms.txt

Use this file to discover all available pages before exploring further.

id
string
required
Sandbox id from POST /v1/sandboxes.
code
string
required
Source code to execute.
language
string
default:"python"
python or bash. Python uses the sandbox’s persistent REPL (state carries across calls); bash runs in a fresh subprocess.
curl -N -X POST https://api.podflare.ai/v1/sandboxes/$SID/exec \
  -H 'content-type: application/json' \
  -d '{"code": "print(6*7)"}'
{"type":"stdout","data":"42","seq":0,"ts":1776510028036}
{"type":"exit","data":0,"seq":1,"ts":1776510028037}

Semantics

  • REPL state persists across Python exec calls. Variables, imports, and open file handles stay alive.
  • Bash does not persist. Each bash exec is a fresh subprocess.
  • Serialized per sandbox. Only one exec runs at a time. Concurrent requests queue; if you want parallelism, fork().
  • Exceptions don’t poison the REPL. An uncaught Python exception produces exit.data != 0 but the next call still works.

Timing

CallWall clock
run_code("print(6*7)") in a warm pool-hit sandbox~3–5 ms
First import pandas (cold file cache)~500 ms
Subsequent import pandas (warm page cache)~150 ms