CodeSandbox SDK – CodeSandbox

CodeSandbox SDK

Programmatically spin up development environments

The CodeSandbox SDK has been designed to let you to rapidly create and run secure code environments at scale. The SDK is already supporting use cases such as:

If your product or project has a need for concurrent VMs, sandboxed development environments and/or an isolated code interpreter. The CodeSandbox SDK has been built with you in mind.

💡

We are currently working on improvements to our infrastructure. Please read our latest Best Practices Release (opens in a new tab) for more details. We would love your feedback!

Quickstart Permalink for this section

  1. Create or log into your CodeSandbox account (opens in a new tab)

  2. Next create an API key at https://codesandbox.io/t/api (opens in a new tab), and enable all scopes. Expose it as CSB_API_KEY in your environment.

  3. Install the SDK:

   npm install @codesandbox/sdk

Your first interaction:

import { CodeSandbox } from "@codesandbox/sdk";

const sdk = new CodeSandbox();
const sandbox = await sdk.sandboxes.create();
const client = await sandbox.connect();

const output = await client.commands.run("echo 'Hello World'");

console.log(output) // Hello World

How to integrate Permalink for this section

To understand how the SDK can be integrated into your product read the following pages: