HTTP API reference
282 endpoints, one base URL, one header. The SDKs, the CLI and the dashboard all go through this API, so anything they do, you can do with curl.
kosa8 run --cloud python:3.12-slim python3 -c 'print(6 * 7)'
# Create a sandbox from the python template SBX=$(curl -s https://api.kosa8.com/v1/sandboxes \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' \ -d '{"template":"python","ttl_s":600}' | jq -r .sandbox.id) # Run a command in it curl -s https://api.kosa8.com/v1/sandboxes/$SBX/exec \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' \ -d '{"cmd":["python3","-c","print(6 * 7)"]}' # Delete it curl -s -X DELETE https://api.kosa8.com/v1/sandboxes/$SBX \ -H "Authorization: Bearer $KOSA8_API_KEY"
from kosa8 import Kosa8Cloud cloud = Kosa8Cloud() # reads KOSA8_API_KEY with cloud.sandboxes.create(template="python", ttl_s=600) as box: r = box.exec(["python3", "-c", "print(6 * 7)"]) print(r.exit_code, r.stdout) # 0 42 # the sandbox is deleted when the block ends
import { Kosa8Cloud } from '@kosa8/sdk'; const cloud = new Kosa8Cloud(); // reads KOSA8_API_KEY const box = await cloud.sandboxes.create({ template: 'python', ttlS: 600 }); try { const r = await box.exec(['python3', '-c', 'print(6 * 7)']); console.log(r.exitCode, r.stdout); // 0 42 } finally { await box.delete(); }
package main import ( "context" "fmt" "log" kosa8 "github.com/kosa8ai/kosa8-go" ) func main() { ctx := context.Background() cloud, err := kosa8.NewCloud(kosa8.CloudOptions{}) // reads KOSA8_API_KEY if err != nil { log.Fatal(err) } box, err := cloud.Sandboxes.Create(ctx, kosa8.CloudCreateOptions{Template: "python", TTLSeconds: 600}) if err != nil { log.Fatal(err) } defer box.Delete(ctx) r, err := box.Exec(ctx, []string{"python3", "-c", "print(6 * 7)"}, nil) if err != nil { log.Fatal(err) } fmt.Print(r.Stdout) // 42 }
require "kosa8" cloud = Kosa8::Cloud.new # reads KOSA8_API_KEY box = cloud.sandboxes.create(template: "python", ttl_s: 600) begin r = box.exec(["python3", "-c", "print(6 * 7)"]) puts r.exit_code, r.stdout # 0, 42 ensure box.delete end
import com.kosa8.*; public class Main { public static void main(String[] args) throws Exception { Kosa8Cloud cloud = Kosa8Cloud.builder().build(); // reads KOSA8_API_KEY CloudSandbox box = cloud.sandboxes().create( new CloudOptions.Create().template("python").ttlSeconds(600)); try { CloudExecResult r = box.exec("python3 -c 'print(6 * 7)'"); System.out.println(r.exitCode() + " " + r.stdout()); // 0 42 } finally { box.delete(); } } }
The basics#
| Base URL | https://api.kosa8.com. Sandboxes run in us-ash1 (Ashburn, Virginia). |
| Auth | Authorization: Bearer k8c_live_…: an API key, or a k8c_tok_… capability token. Keys and scopes |
| Bodies | JSON in, JSON out; file bodies are raw bytes; a streamed exec answers NDJSON |
| Errors | {"error": "code", "message": "…"}, with a stable error code. Errors and retries |
| Safe retries | Send Idempotency-Key on creates: for 24 hours a repeat gets the first answer |
| Machine-readable | openapi.json (OpenAPI 3.1), llms.txt, and an MCP server at /mcp |
Sandboxes#
Sandboxes26 endpoints, e.g.
GET /v1/sandboxes
Sandbox files5 endpoints, e.g. GET /v1/sandboxes/{id}/files
Checkpoints4 endpoints, e.g. GET /v1/checkpoints
Snapshots4 endpoints, e.g. GET /v1/snapshots
Terminal and large files4 endpoints, e.g. POST /v1/sandboxes/{id}/terminal
Previews5 endpoints, e.g. GET /v1/sandboxes/{id}/previews
Egress6 endpoints, e.g. GET /v1/egress/presets
Secrets4 endpoints, e.g. GET /v1/secrets
Recordings4 endpoints, e.g. GET /v1/recordings
Embeds3 endpoints, e.g. POST /v1/sandboxes/{id}/embed
Observability3 endpoints, e.g. GET /v1/sandboxes/{id}/metrics
Schedules4 endpoints, e.g. GET /v1/sandboxes/{id}/schedules
Serverless and compute#
Functions14 endpoints, e.g.
GET /v1/functions
Code interpreter5 endpoints, e.g. POST /v1/sandboxes/{id}/code
Browsers6 endpoints, e.g. POST /v1/browsers
AI gateway7 endpoints, e.g. GET /v1/ai/keys
Machines5 endpoints, e.g. GET /v1/overview
RL, jobs and CI#
RL runs12 endpoints, e.g.
GET /v1/rl/compare
Jobs5 endpoints, e.g. POST /v1/jobs
Benchmarks5 endpoints, e.g. GET /v1/benchmarks
Pipelines11 endpoints, e.g. GET /v1/pipelines/runs
Swarms6 endpoints, e.g. GET /v1/swarms
Organization#
Account17 endpoints, e.g.
GET /v1/me
API keys9 endpoints, e.g. GET /v1/api-keys
Team10 endpoints, e.g. GET /v1/members
Sign-in12 endpoints, e.g. POST /v1/auth/device
Billing24 endpoints, e.g. POST /v1/billing/checkout
Own hosts5 endpoints, e.g. GET /v1/byoc/tokens
Custom domains8 endpoints, e.g. GET /v1/sandboxes/{id}/previews/{port}/domains
Security#
Security10 endpoints, e.g.
GET /v1/security/posture
Audit3 endpoints, e.g. GET /v1/audit
Attack tests3 endpoints, e.g. GET /v1/attack/scorecards
Threat feed3 endpoints, e.g. GET /v1/threats
Webhooks9 endpoints, e.g. GET /v1/webhooks
Integrations5 endpoints, e.g. GET /v1/integrations/github
Store16 endpoints, e.g. GET /v1/store/items