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

# Sandbox API Overview

> How the GMI Sandbox control plane and data plane fit together, and which token each one expects.

GMI Sandbox provides isolated execution environments created from templates. The REST API is split
into two planes with **different hosts and different credentials**. Knowing which plane an endpoint
belongs to is the key to using the API correctly.

## Control plane vs. data plane

| | Control plane | Data plane |
| - | - | - |
| What it does | Lifecycle: create, list, connect, extend, pause, resume, delete sandboxes; manage templates and snapshots | Work inside one sandbox: run commands, open an interactive shell, upload/download files |
| Base URL | `https://console.gmicloud.ai/api/v2` | `https://{sandbox_key}.{domain}` (per sandbox) |
| Auth header | `Authorization: Bearer <API key>` | `X-Access-Token: <sandbox_access_token>` |
| Endpoints | `/sandboxes`, `/snapshots`, `/templates`, `/products` | `/executions`, `/shell`, `/shell/connect`, `/shell/control`, `/files` |
| Response shape | `{request_id, data}` envelope; list endpoints return `items` and `total` | No `{request_id, data}` envelope: successful responses are flat JSON (with a top-level `request_id`) or raw bytes (`/files` downloads); errors use `{code, message, request_id}` |

The two credentials are **not interchangeable**: the control plane rejects `X-Access-Token`, and the
data plane rejects `Authorization: Bearer`. This includes the shell endpoints: `POST /shell`,
the WebSocket handshake on `GET /shell/connect` and `POST /shell/control` all use
`X-Access-Token`. A data-plane token is bound to its sandbox. Using sandbox A's token against
sandbox B's host fails.

## Where the data-plane values come from

Every successful create (`POST /sandboxes`) or connect (`POST /sandboxes/{id}/connect`) response
returns three fields:

* `sandbox_key`: the per-sandbox host label;
* `domain`: the host suffix. Combine them as `https://{sandbox_key}.{domain}`; never assemble or
  derive the domain yourself;
* `sandbox_access_token`: the data-plane credential, valid for the sandbox's entire lifetime.

After extending a sandbox's lifetime (via connect or the timeout endpoint) or resuming a paused
sandbox, call connect again and overwrite all three cached values. The token may have been re-signed.

## Typical flow

1. `POST /sandboxes` with a `template_id` (send an `Idempotency-Key` header to make retries safe);
2. wait for the sandbox to reach `running` (`GET /sandboxes/{id}`);
3. run commands and transfer files against the sandbox's own host using `X-Access-Token`;
4. extend the lifetime with `POST /sandboxes/{id}/timeout` as needed;
5. optionally pause with `POST /sandboxes/{id}/pause` and later `POST /sandboxes/{id}/resume`,
   then call connect again once the sandbox is `running`;
6. `DELETE /sandboxes/{id}` when done. Sandboxes also expire automatically at `end_at`.

Prefer a higher-level interface? The [Python SDK](https://docs.gmicloud.ai/agentbox-api/sandbox-sdk/usage.md) wraps both
planes behind one client.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.