Skip to main content

StateSet Sandbox

StateSet Sandbox is a Kubernetes-based sandbox infrastructure for running code execution workloads inside isolated pods. It exposes REST and WebSocket APIs for creating sandboxes, streaming command output, and reading or writing files inside each sandbox workspace. Sign up for a free API Key at sandbox.stateset.app.

Sandbox SDK (Node.js)

Use the Node.js SDK to create sandboxes, execute commands, and manage files.

Install

npm install @stateset/sandbox-sdk

Initialize the Client

import { StateSetSandbox } from '@stateset/sandbox-sdk';

const client = new StateSetSandbox({
  baseUrl: 'https://api.sandbox.stateset.app',
  authToken: 'sk-sandbox-YOUR_API_KEY',
  orgId: 'org_YOUR_ORG_ID'
});

Create and Execute

const sandbox = await client.create({ timeout_seconds: 300 });
const result = await client.execute(sandbox.sandbox_id, {
  command: ['python3', '-c', 'print("Hello from StateSet!")']
});

File Operations

await client.writeFiles(sandbox.sandbox_id, [
  { path: '/workspace/hello.txt', content: Buffer.from('Hello!').toString('base64') }
]);

const file = await client.readFiles(sandbox.sandbox_id, ['/workspace/hello.txt']);

Cleanup

await client.stop(sandbox.sandbox_id);