Skip to content
Home

Create Your First Sandbox

This quickstart creates a sandbox from base, writes a file, runs a shell command, prints the result, and deletes the sandbox.

You need:

  • A SeaCloud API key that can create sandboxes.
  • Access to the base official template in the target environment.
  • Node.js, Python, or Go installed locally.
  • Network access from your runtime to https://sandbox-gateway.cloud.seaart.ai.

Create a SeaCloud API key, then export the gateway URL and token in your shell or runtime secret manager.

Terminal window
export SEACLOUD_BASE_URL="https://sandbox-gateway.cloud.seaart.ai"
export SEACLOUD_API_KEY="YOUR_API_KEY"
Terminal window
npm install @seacloudai/sandbox
import { Sandbox } from "@seacloudai/sandbox";
const sandbox = await Sandbox.create("base", {
waitReady: true,
timeout: 1800,
});
try {
await sandbox.files.write("/root/workspace/hello.txt", "hello from node\n");
const run = await sandbox.commands.run("sh", {
args: ["-lc", "pwd && cat /root/workspace/hello.txt"],
});
console.log(run.exitCode, run.stdout);
} finally {
await sandbox.delete();
}

The command should print an exit code of 0 and output similar to:

/root/workspace
hello from node

Language-specific stdout wrappers may differ, but a successful run has three properties:

  1. The sandbox reaches running.
  2. The file under /root/workspace/hello.txt is readable.
  3. Cleanup calls delete() without a lifecycle error.
StepAPI surface
Create sandboxPOST /api/v1/sandboxes through the SDK
Wait for readinesswaitReady: true waits until runtime APIs can be used
Write a fileRuntime filesystem APIs behind sandbox.files
Run a commandRuntime process APIs behind sandbox.commands
Delete sandboxDELETE /api/v1/sandboxes/:sandboxID through sandbox.delete()
SymptomCheck
401 or 403SEACLOUD_API_KEY is present, valid, and scoped to the target project.
template not foundList official templates in the target environment and confirm base is visible.
Sandbox waits too longIncrease lifecycle timeout; check sandbox detail for timeline and diagnostic.
Runtime credentials are missingFetch sandbox detail and confirm envdUrl and envdAccessToken are present.
Command times outIncrease runtime command timeoutMs; this is milliseconds, not seconds.
Cleanup failsRetry delete() with the sandbox ID, then check lifecycle state.

Use this when SDK setup fails and you want to verify the gateway/API key first:

Terminal window
curl -sS "${SEACLOUD_BASE_URL}/api/v1/sandboxes" \
-H "X-API-Key: ${SEACLOUD_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"templateID": "base",
"timeout": 1800,
"waitReady": true
}' | jq .

Save the returned sandboxID and delete it after the test:

Terminal window
curl -sS -X DELETE "${SEACLOUD_BASE_URL}/api/v1/sandboxes/${SANDBOX_ID}" \
-H "X-API-Key: ${SEACLOUD_API_KEY}" -i