kosa8 docs Dashboard
esc
↑ ↓ move↵ openRuns in your browser; nothing you type is sent anywhere.

Core concepts

Files

Files go in and out as raw bytes, no base64 and no multipart. Keep what matters under /workspace, the part of the sandbox that lasts. A sleeping sandbox wakes for a file call.

ID=$(kosa8 cloud sandbox create --template python --ttl 15m --json | jq -r .sandbox.id)

echo 'print("hello from a file")' > hello.py
kosa8 cloud files put $ID hello.py /workspace/hello.py
kosa8 cloud sandbox exec $ID -- python3 /workspace/hello.py > out.txt
kosa8 cloud files ls $ID /workspace
kosa8 cloud files get $ID /workspace/hello.py      # to stdout
cat out.txt

kosa8 cloud sandbox rm $ID
API=https://api.kosa8.com/v1
AUTH="Authorization: Bearer $KOSA8_API_KEY"
SBX=$(curl -s $API/sandboxes -H "$AUTH" -H 'Content-Type: application/json' \
  -d '{"template":"python","ttl_s":900}' | jq -r .sandbox.id)

# Upload: the request body is the file, streamed, any size
curl -s -X PUT "$API/sandboxes/$SBX/files?path=/workspace/hello.py" -H "$AUTH" \
  --data-binary 'print("hello from a file")' > /dev/null

# Download, and list the folder
curl -s "$API/sandboxes/$SBX/files?path=/workspace/hello.py" -H "$AUTH"; echo
curl -s "$API/sandboxes/$SBX/files/list?path=/workspace" -H "$AUTH" | jq -c '.files[] | {name, size}'

curl -s -X DELETE $API/sandboxes/$SBX -H "$AUTH"
from kosa8 import Kosa8Cloud

cloud = Kosa8Cloud()

with cloud.sandboxes.create(template="python", ttl_s=900) as box:
    box.files.write("/workspace/hello.py", 'print("hello from a file")\n')
    print(box.exec(["python3", "/workspace/hello.py"]).stdout)   # hello from a file
    print(box.files.read_text("/workspace/hello.py"))
    for f in box.files.list("/workspace"):
        print(f["name"], f["size"])
import { Kosa8Cloud } from '@kosa8/sdk';

const cloud = new Kosa8Cloud();
const box = await cloud.sandboxes.create({ template: 'python', ttlS: 900 });
try {
  await box.files.write('/workspace/hello.py', 'print("hello from a file")\n');
  console.log((await box.exec(['python3', '/workspace/hello.py'])).stdout); // hello from a file
  console.log(await box.files.readText('/workspace/hello.py'));
  for (const f of await box.files.list('/workspace')) console.log(f.name, f.size);
} finally {
  await box.delete();
}

The calls#

CallDoes
PUT /v1/sandboxes/{id}/files?path=…Write a file; the body is its bytes, streamed (100 MB per request; larger files go in parts or by direct link)
GET /v1/sandboxes/{id}/files?path=…Read it back, streamed; Range headers work
GET /v1/sandboxes/{id}/files/list?path=…List a folder (default /workspace) as {"files": [...]}
POST /v1/sandboxes/{id}/files/mkdirMake a folder and its parents
DELETE /v1/sandboxes/{id}/files?path=…Remove a file, or a folder with recursive=1

The exact parameters are in the API reference. For files of many megabytes, appends, offsets and direct upload links, see terminal and large files.

Tips#

  • To send a whole project, tar it, put one file, and untar it with one exec. That is far faster than one call per file.
  • Results you want to keep must be read out before the sandbox is deleted, or saved in a snapshot.

Something wrong or missing? Edit this page, or write to contact@kosa8.com.

The kosa8 weekly

Agent security news, one industry deep-dive and a hands-on challenge, every Monday. Unsubscribe in one click.

© 2026 kosa8 · kosa8.com · AI Agent Sandbox: Secure and Sovereign for Enterprise · Local models served by llamay · Agent gateway: MAQPNA