# Programmatic Sandbox Management Alternatives Using the CubeSandbox WebUI Console API

> Explore programmatic sandbox management alternatives using the CubeSandbox WebUI console API. Replace dashboard actions with direct HTTP calls, SDKs, or OpenAPI clients for enhanced control.

- Repository: [Tencent Cloud/CubeSandbox](https://github.com/TencentCloud/CubeSandbox)
- Tags: api-reference
- Published: 2026-07-03

---

**The CubeSandbox WebUI console is a thin React client that consumes the same E2B-compatible REST API available to programmatic clients, allowing you to replace dashboard interactions with direct HTTP calls, the Go/Python SDKs, the cubecli binary, or generated OpenAPI clients.**

The TencentCloud CubeSandbox repository provides a complete sandbox environment with a React-based WebUI console. While the dashboard offers a convenient visual interface for managing sandboxes, it is merely a consumer of the underlying CubeAPI, which exposes a fully RESTful interface at `/cubeapi/v1/*`. This means every action performed in the browser can be replicated programmatically using several first-class alternatives that share identical authentication and request semantics.

## Understanding the WebUI Console Architecture

The CubeSandbox dashboard, located in the `web/` directory, is built with React and Vite. According to the project documentation in [`web/README.md`](https://github.com/TencentCloud/CubeSandbox/blob/main/web/README.md), all UI actions invoke HTTP calls under the `/cubeapi/v1/*` prefix. The thin client wrapper in [`web/src/lib/api.ts`](https://github.com/TencentCloud/CubeSandbox/blob/main/web/src/lib/api.ts) translates user interactions into standardized REST requests, proving that the WebUI is essentially a browser-based REST client.

Because the dashboard uses the same endpoints as programmatic clients, you can inspect the network calls in your browser to determine the exact payload structure, then replicate those requests using any HTTP client or official SDK.

## Programmatic Management Alternatives

Since the WebUI is a thin client for the CubeAPI, you can manage sandboxes programmatically using any of these equivalent methods:

### Raw HTTP and cURL

Any HTTP client can communicate directly with the CubeAPI because it is fully documented and serves an OpenAPI specification. The server listens on port `3000` by default and accepts requests at `http://<host>:3000/cubeapi/v1/...`.

Authentication uses the `X-API-Key` header or a Bearer token via the `Authorization` header. This method is ideal for rapid prototyping, debugging, or integration with existing shell scripts.

### Official Go SDK

The Go SDK provides strongly typed wrappers for the REST API. Core implementation lives in [`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go) (HTTP transport and authentication) and [`sdk/go/sandbox.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/sandbox.go) (high-level lifecycle helpers). Import `github.com/tencentcloud/CubeSandbox/sdk/go` to create sandboxes, execute commands, and manage networking with compile-time safety.

### Official Python SDK

The `cubesandbox` PyPI package mirrors the Go SDK surface area. It implements the same HTTP client logic in Python, making it suitable for data science workflows and Python-based automation. The source structure and authentication handling align with the Go implementation, ensuring behavioral consistency across languages.

### CubeCLI Tool

The `cubecli` binary, shipped with Cubelet, provides command-line access to the same features available in the UI. Located in `Cubelet/cmd/cubecli/`, this CLI uses the Go SDK under the hood to call `/cubeapi/v1/*` endpoints. It is optimized for automation, CI/CD pipelines, and one-off administrative tasks.

### Generated OpenAPI Clients

The CubeAPI process serves an OpenAPI specification at `http://<host>:3000/openapi.json`. You can use tools like `openapi-generator` to create type-safe clients for Node.js, Java, Rust, or any other language. This approach ensures your client code stays synchronized with the server implementation.

## Code Examples

The following examples demonstrate how to list sandboxes, create new instances, and execute commands using different programmatic approaches. Each method ultimately calls the same endpoints defined in [`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go).

### List Sandboxes with cURL

This raw HTTP request hits the same endpoint that the WebUI's "Sandboxes" page calls (as implemented in [`web/src/lib/api.ts`](https://github.com/TencentCloud/CubeSandbox/blob/main/web/src/lib/api.ts)):

```bash
curl -s -H "X-API-Key: $CUBE_API_KEY" \
     http://127.0.0.1:3000/cubeapi/v1/sandboxes | jq .

```

### Create and Execute with the Go SDK

This example uses the Go SDK ([`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go) and [`sdk/go/sandbox.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/sandbox.go)) to create a sandbox from a template and run a command:

```go
package main

import (
	"context"
	"log"
	"time"

	cs "github.com/tencentcloud/CubeSandbox/sdk/go"
)

func main() {
	// Configure client using the same environment variables the dashboard reads
	client := cs.NewClient(cs.Config{
		APIURL: "http://127.0.0.1:3000",
		APIKey: "my‑api‑key",
	})

	// Create a sandbox from a template (template ID visible in the UI's Templates page)
	sandbox, err := client.NewSandbox(context.Background(),
		cs.SandboxParams{
			TemplateID: "tpl‑python‑3‑10",
			Env:        map[string]string{"PYTHONUNBUFFERED": "1"},
		})
	if err != nil {
		log.Fatalf("sandbox create: %v", err)
	}
	defer sandbox.Delete(context.Background()) // clean‑up

	// Execute a command inside the sandbox
	out, err := sandbox.Exec(context.Background(),
		cs.ExecParams{Cmd: []string{"python", "- <<'PY'\nprint('hello from sandbox')\nPY"}})
	if err != nil {
		log.Fatalf("exec: %v", err)
	}
	log.Printf("Command output: %s", out.Stdout)
}

```

### Python SDK Workflow

Using the official Python SDK (documented in [`sdk/python/README.md`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/python/README.md)):

```python
from cubesandbox import Client

c = Client(
    api_url="http://127.0.0.1:3000",
    api_key="my-api-key"
)

# Create sandbox from a template

sb = c.sandbox.create(template_id="tpl-python-3-10")
try:
    # Run a Python one‑liner

    result = sb.exec(["python", "- <<'PY'\nprint('hello from python sandbox')\nPY"])
    print("stdout:", result.stdout)
finally:
    sb.delete()

```

### CLI One-Liners

The `cubecli` command uses the Go SDK to interact with the API:

```bash

# List all sandboxes

cubecli sandbox list

# Create and execute (hypothetical usage based on CLI patterns)

cubecli sandbox create --template tpl-python-3-10

```

### Generate a Node.js Client

Fetch the OpenAPI spec from the running server to generate a custom client:

```bash

# Fetch the spec

curl -s http://127.0.0.1:3000/openapi.json > cubeapi.json

# Generate a Node client (requires openapi-generator)

openapi-generator generate -i cubeapi.json -g javascript -o ./cubeapi-client

```

## Key Implementation Files

Understanding these source files helps when debugging or extending programmatic integrations:

- **[`web/src/lib/api.ts`](https://github.com/TencentCloud/CubeSandbox/blob/main/web/src/lib/api.ts)** – The UI's HTTP client wrapper that translates dashboard actions into `/cubeapi/v1/*` calls.
- **[`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go)** – Core HTTP client handling authentication and request serialization for the Go ecosystem.
- **[`sdk/go/sandbox.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/sandbox.go)** – High-level sandbox lifecycle management (create, exec, delete, snapshots).
- **[`sdk/python/README.md`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/python/README.md)** – Documentation for the Python SDK that mirrors the Go implementation.
- **`Cubelet/cmd/cubecli/`** – Source directory for the CLI tool that consumes the Go SDK.
- **[`CubeAPI/README.md`](https://github.com/TencentCloud/CubeSandbox/blob/main/CubeAPI/README.md)** – Documentation for the REST API entry point on port 3000.

## Summary

- The CubeSandbox WebUI console is a thin React client that consumes the same REST API available to programmatic users.
- All dashboard actions map to `/cubeapi/v1/*` endpoints defined in the CubeAPI server.
- You can manage sandboxes programmatically using raw HTTP/cURL, the official Go SDK, the Python SDK, the cubecli binary, or generated OpenAPI clients.
- Authentication is consistent across all methods using the `X-API-Key` header or Bearer tokens.
- The Go SDK ([`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go)) and Python SDK provide type-safe wrappers ideal for production services and scripts.

## Frequently Asked Questions

### Is the WebUI console API different from the CubeAPI REST endpoints?

No. The WebUI console is merely a React client that consumes the CubeAPI. According to the source code in [`web/src/lib/api.ts`](https://github.com/TencentCloud/CubeSandbox/blob/main/web/src/lib/api.ts), every UI action translates directly to HTTP calls against `/cubeapi/v1/*`. There is no separate "console API"—the dashboard uses the exact same endpoints available to programmatic clients.

### How do I authenticate programmatic requests to the CubeSandbox API?

Authentication uses the `X-API-Key` header or an `Authorization: Bearer <token>` header. This is implemented consistently in [`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go) and applies to all programmatic alternatives, including the Python SDK, CLI, and raw HTTP requests. The WebUI reads the same API key configuration to make its requests.

### Can I use the Python SDK for production workloads, or should I use the Go SDK?

Both SDKs are first-class citizens. The Python SDK mirrors the Go implementation and issues identical REST calls, making it suitable for data science pipelines and Python-centric automation. The Go SDK offers compile-time type safety and is preferred for long-running services or infrastructure tooling. Choose based on your stack, as the underlying API behavior is identical.

### What is the relationship between cubecli and the Go SDK?

The `cubecli` binary is a command-line wrapper around the Go SDK. Its source in `Cubelet/cmd/cubecli/` imports the SDK from [`sdk/go/client.go`](https://github.com/TencentCloud/CubeSandbox/blob/main/sdk/go/client.go) to execute commands. This means CLI operations have the same performance characteristics and API compatibility as direct Go SDK usage, making it ideal for CI/CD automation and shell scripting.