> ## 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.

# Create a new sandbox

> Creates a new isolated Kubernetes pod for code execution

Creates a new isolated Kubernetes pod for code execution

### Request body

`CreateSandboxRequest`

<ParamField body="org_id" type="string" required>
  Organization ID
</ParamField>

<ParamField body="session_id" type="string">
  Optional session ID (auto-generated if not provided)
</ParamField>

<ParamField body="cpus" type="string">
  CPU limit (e.g., '2', '500m')
</ParamField>

<ParamField body="memory" type="string">
  Memory limit (e.g., '2Gi', '512Mi')
</ParamField>

<ParamField body="isolation" type="string">
  Optional isolation level (container, gvisor, microvm)
</ParamField>

<ParamField body="timeout_seconds" type="integer">
  Timeout in seconds (30-3600)
</ParamField>

<ParamField body="env" type="object">
  Environment variables to inject
</ParamField>

### Response

`CreateSandboxResponse`

<ResponseField name="sandbox_id" type="string (uuid)" />

<ResponseField name="session_id" type="string" />

<ResponseField name="status" type="SandboxStatusEnum" />

<ResponseField name="expires_at" type="string (date-time)" />

### Status codes

| Code  | Meaning                      |
| ----- | ---------------------------- |
| `200` | Sandbox created successfully |
| `400` | —                            |
| `401` | —                            |
| `500` | —                            |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.sandbox.stateset.app/api/v1/sandbox/create' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "org_id": "string",
    "session_id": "string",
    "cpus": "string",
    "memory": "string",
    "isolation": "container",
    "timeout_seconds": 1,
    "env": {}
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "sandbox_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "session_id": "string",
    "status": "creating",
    "expires_at": "2026-07-24T12:00:00Z"
  }
  ```
</ResponseExample>
