The TypeScript SDK is @sandscale/sdk. It needs Node.js 22 or later and has no runtime dependencies. The Python SDK is listed as coming soon, so use the TypeScript SDK or the REST API today.
Set up the client
npm install @sandscale/sdkimport { Sandscale } from '@sandscale/sdk';
const sandscale = new Sandscale({ apiKey: process.env.SANDSCALE_API_KEY });Create one client and reuse it. Every call also takes a region; pass back the region that a sandbox came with.
Create
const box = await sandscale.sandboxes.create({ template: 'builtin:python', timeoutSeconds: 3600, name: 'try-it' });Built-in templates include builtin:python, builtin:node, builtin:go and builtin:base. What you can start depends on your plan and your organization's policy; a request beyond them is refused before anything starts.
Run a command
const run = await sandscale.sandboxes.run(box.id, ['python3', '-c', 'print(6 * 7)'], { region: box.region });
console.log(run.exitCode, run.stdout);Pass onStdout or onStderr to get the output live.
Upload and download files
await sandscale.sandboxes.writeFile(box.id, '/workspace/hello.py', 'print("hi")', { region: box.region });
const files = await sandscale.sandboxes.listFiles(box.id, '/workspace', { region: box.region });
const data = await sandscale.sandboxes.readFile(box.id, '/workspace/hello.py', { region: box.region });Pause, resume and snapshot
await sandscale.sandboxes.pause(box.id, { region: box.region });
await sandscale.sandboxes.resume(box.id, { region: box.region });
const snap = await sandscale.sandboxes.snapshot(box.id, { region: box.region, label: 'after-npm-ci' });Stop
await sandscale.sandboxes.stop(box.id, { region: box.region });A sandbox also stops by itself when its timeout runs out. Always stop sandboxes you no longer need.
Errors and retries
Every API error raises a SandscaleError with the status, code, message and request ID. Catch a family with its subclass, for example ConflictError (409, such as a paused or ended sandbox), LimitExceededError (402 or a quota code), RateLimitError (429) or EntitlementError (your plan does not include it, or payment is required). Only reads are retried automatically; calls that change something are sent once.
More: SDKs and the TypeScript reference.