Skip to content

Create Environment

POST/v1/environments

Create an environment. An environment defines the container configuration — packages and networking — that agent sessions run in.

Claude API compatibility

SandBase implements the cloud environment type from the Claude Managed Agents Environment API. The self_hosted type and scope field are accepted for forward compatibility but not yet active.

Request Parameters

ParameterTypeRequiredDescription
namestringHuman-readable name for the environment.
descriptionstringOptional description.
configobjectEnvironment configuration. Defaults to a cloud environment with unrestricted networking and no extra packages.
metadataobjectArbitrary key-value metadata.

Config Object

For a cloud environment, config has the following shape:

json
{
  "type": "cloud",
  "networking": { "type": "unrestricted" },
  "packages": {
    "type": "packages",
    "pip": ["pandas", "numpy"],
    "npm": ["express"]
  }
}
FieldTypeDescription
typestring"cloud"
networkingobjectNetwork access policy. See Networking.
packagesobjectPackages to preinstall. See Packages.

SandBase extension — base_template

SandBase sandboxes are template-based. You may include an optional base_template field in the cloud config (e.g. "code_interpreter", "hermes") to select the base image. If omitted, a default base is used and packages are layered on top. See Templates.

Networking

The networking field is a discriminated union on type.

Unrestricted

json
{ "type": "unrestricted" }

Full outbound network access.

Limited

json
{
  "type": "limited",
  "allowed_hosts": ["api.example.com"],
  "allow_mcp_servers": false,
  "allow_package_managers": true
}
FieldTypeDefaultDescription
allowed_hostsstring[][]Domains the container can reach.
allow_mcp_serversbooleanfalseAllow outbound access to the agent's configured MCP endpoints, beyond allowed_hosts.
allow_package_managersbooleanfalseAllow outbound access to public package registries (PyPI, npm, etc.), beyond allowed_hosts.

Packages

Preinstall packages by manager. Use the version syntax of each manager (e.g. package==1.0.0 for pip). Unversioned installs the latest.

json
{
  "type": "packages",
  "apt": ["ffmpeg"],
  "pip": ["pandas", "numpy==1.26.0"],
  "npm": ["express"],
  "go": [],
  "cargo": [],
  "gem": []
}
FieldTypeDescription
aptstring[]Ubuntu/Debian packages
pipstring[]Python packages
npmstring[]Node.js packages
gostring[]Go packages
cargostring[]Rust packages
gemstring[]Ruby packages

Request Examples

python
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-sb-YOUR_KEY",
    base_url="https://api.sandbase.ai"
)

env = client.beta.environments.create(
    name="python-data-analysis",
    description="Python environment with data-analysis packages.",
    config={
        "type": "cloud",
        "networking": { "type": "limited", "allowed_hosts": ["api.example.com"], "allow_package_managers": True },
        "packages": { "type": "packages", "pip": ["pandas", "numpy"] }
    }
)
print(env.id)
bash
curl -X POST https://api.sandbase.ai/v1/environments \
  -H "Authorization: Bearer sk-sb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "python-data-analysis",
    "config": {
      "type": "cloud",
      "networking": { "type": "limited", "allowed_hosts": ["api.example.com"], "allow_package_managers": true },
      "packages": { "type": "packages", "pip": ["pandas", "numpy"] }
    }
  }'

Response

Returns an Environment object.

json
{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "type": "environment",
  "name": "python-data-analysis",
  "description": "Python environment with data-analysis packages.",
  "config": {
    "type": "cloud",
    "networking": {
      "type": "limited",
      "allowed_hosts": ["api.example.com"],
      "allow_mcp_servers": false,
      "allow_package_managers": true
    },
    "packages": {
      "type": "packages",
      "apt": [],
      "cargo": [],
      "gem": [],
      "go": [],
      "npm": [],
      "pip": ["pandas", "numpy"]
    }
  },
  "metadata": {},
  "archived_at": null,
  "created_at": "2026-05-29T10:00:00Z",
  "updated_at": "2026-05-29T10:00:00Z"
}

Environment Object

FieldTypeDescription
idstringEnvironment identifier (env_...)
typestringAlways "environment"
namestringHuman-readable name
descriptionstringUser-provided description
configobjectCloud configuration (networking, packages)
metadataobjectUser-defined key-value pairs
archived_atstring | nullRFC 3339 timestamp when archived
created_atstringRFC 3339 timestamp
updated_atstringRFC 3339 timestamp

Roadmap

Claude's Environment also supports a self_hosted config type and an organization/account scope field. These are not yet active in SandBase.

Errors

StatusTypeDescription
400invalid_requestMissing required fields or invalid config
401authentication_errorInvalid or missing API key