Skip to main content
Source: start-sandbox/ Sometimes you want a managed remote workspace you drive yourself — for tooling, batch jobs, or programmatic agents — without a full conversation. This example creates a sandbox, waits for it to be ready, then executes shell commands directly on the agent-server.

Two Servers

OpenHands uses two separate servers: The session_api_key is different from your Cloud API key — it’s returned by the sandbox-create response.

The Flow

Quickstart

How It Works

1. Create the Sandbox

2. Poll Until Running

The sandbox starts asynchronously. Poll until status == "RUNNING":

3. Locate the Agent Server

The sandbox response includes an exposed_urls list. Find the one named "AGENT_SERVER":

4. Run Commands

Use POST /api/bash/execute_bash_command to run shell commands:

Example Output

Cleanup

The example intentionally leaves the sandbox running. To delete it:
The OpenAPI schema for the agent-server is available at {agent_url}/openapi.json once the sandbox is RUNNING.

See Also

  • Clone and Attach — Builds on this: clones a repo, runs its setup script, then attaches a conversation to the prepared sandbox
  • Test MCP Config — Uses a sandbox to validate MCP server configurations before use