> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox SDK (Node.js)

> Node.js SDK usage for creating and managing sandboxes.

# 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](https://sandbox.stateset.app).

# Sandbox SDK (Node.js)

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

## Install

```bash theme={null}
npm install @stateset/sandbox-sdk
```

## Initialize the Client

```typescript theme={null}
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

```typescript theme={null}
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

```typescript theme={null}
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

```typescript theme={null}
await client.stop(sandbox.sandbox_id);
```

## Related Documentation

* [Quickstart](/stateset-sandbox/QUICKSTART)
* [API Reference](/stateset-sandbox/API_REFERENCE)
