Skip to main content
Configure agent environment

Cloud Environments

Choose the container, network, and dependencies your agent runs in.

An Environment defines the runtime used by a Session, including its environment type, preinstalled dependencies, setup script, and metadata. You can use the default managed Environment, create an Environment with tools for a specific task, or connect a self-hosted runtime.

What an Environment Is

An Environment is the infrastructure layer beneath a Session:
  • Environment type - cloud for managed cloud containers, or self_hosted for self-hosted execution.
  • Packages - preinstalled system, Python, and Node.js dependencies.
  • Setup script - a user shell script run after package installation during container preparation.
When a Session starts, a dedicated runtime instance is created from the specified Environment template.

Field Reference

FieldTypeRequiredDescription
idstring-System-generated, prefixed with env_
typestring-Always "environment"
namestringYesEnvironment name
descriptionstringNoFree-form description; defaults to ""
configobjectNoEnvironment configuration; omission defaults to {"type":"cloud"}
config.typestringYes when config is presentEnvironment type: "cloud" or "self_hosted"
config.packagesobjectNoPreinstalled package configuration for cloud environments
config.setup_scriptstringNoShell script run during sandbox preparation (max 64 KB)
metadataobjectNoCustom key/value metadata
archived_atstring|null-Archive time (ISO 8601), null when not archived
created_atstring-Creation timestamp
updated_atstring-Last update timestamp

Config Types

config.type can be "cloud" or "self_hosted". For self_hosted, the config can contain the type and an optional setup_script:
{"type": "self_hosted"}
Self-hosted Environments do not launch a managed cloud container. External workers use the Work API to poll, acknowledge, heartbeat, and stop Session work for that Environment. A self_hosted config supports only type and an optional setup_script. For cloud, the config can include packages and setup_script.

Preinstalled Packages

Use config.packages to specify dependencies installed when the container starts:
{
  "config": {
    "type": "cloud",
    "packages": {
      "apt": ["git", "build-essential", "libssl-dev"],
      "pip": ["pandas", "numpy", "scikit-learn"],
      "npm": ["typescript", "eslint", "prettier"]
    }
  }
}
Package managerFieldDescription
aptpackages.aptDebian/Ubuntu system packages
pippackages.pipPython packages
npmpackages.npmNode.js packages
Preinstalled packages add to environment startup time. Only include packages you really need; install the rest on demand within the Session.

Setup Script

config.setup_script is a shell script executed during sandbox preparation, after packages are installed. It runs through /bin/bash -lc. Use it for initialization steps that cannot be expressed as packages - for example, cloning a repository, writing config files, or warming caches.
ConstraintValue
Typestring
Max length64 KB
Interpreter/bin/bash -lc
Timeout10 minutes
When it runsSandbox preparation, after packages installation
# Create an environment that clones the project and warms its dependency cache
curl -s -X POST https://api.qoder.com/api/v1/cloud/environments \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "node-with-init",
    "config": {
      "type": "cloud",
      "packages": {
        "npm": ["pnpm@9"]
      },
      "setup_script": "set -euo pipefail\n[ -d /data/workspace/repo/.git ] || git clone https://github.com/me/repo /data/workspace/repo\ncd /data/workspace/repo && pnpm install --frozen-lockfile"
    }
  }' | jq .
On success a completion marker is written inside the sandbox so the script does not run twice in the same sandbox; when the sandbox is recreated, the script runs again. A non-zero exit aborts session startup, and the error response includes the exit code and a stderr excerpt.

Create an Environment

# Create a data-science Environment
curl -s -X POST https://api.qoder.com/api/v1/cloud/environments \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "data-science",
    "config": {
      "type": "cloud",
      "packages": {
        "apt": ["build-essential"],
        "pip": ["pandas", "numpy", "matplotlib", "scikit-learn", "jupyter"]
      }
    }
  }' | jq .
A successful call returns 200 OK:
{
  "id": "env_019e44eb66bb748cabcd1489f6fa4428",
  "type": "environment",
  "name": "data-science",
  "description": "",
  "config": {
    "type": "cloud",
    "packages": {
      "type": "packages",
      "apt": ["build-essential"],
      "cargo": [],
      "gem": [],
      "go": [],
      "npm": [],
      "pip": ["pandas", "numpy", "matplotlib", "scikit-learn", "jupyter"]
    }
  },
  "metadata": {},
  "archived_at": null,
  "created_at": "2026-05-18T10:00:00Z",
  "updated_at": "2026-05-18T10:00:00Z"
}

Read Environments

# List all Environments
curl -s https://api.qoder.com/api/v1/cloud/environments \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN"
# Get a single Environment
curl -s https://api.qoder.com/api/v1/cloud/environments/env_ds456 \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN"

Update an Environment

# Add new dependencies to an existing Environment
curl -s -X POST https://api.qoder.com/api/v1/cloud/environments/env_ds456 \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "data-science",
    "config": {
      "type": "cloud",
      "packages": {
        "apt": ["build-essential", "libpq-dev"],
        "pip": ["pandas", "numpy", "matplotlib", "scikit-learn", "jupyter", "sqlalchemy"]
      }
    }
  }' | jq .
Updating an Environment does not affect running Sessions. The new configuration applies to Sessions created after the update.

Choosing an Environment

ScenarioRecommended configuration
General developmentdefault Environment, no extra setup
Data analysisPreinstall pandas/numpy and verify dependency-registry connectivity
Frontend developmentPreinstall the Node.js toolchain and verify npm-registry connectivity
CI/CD integrationPreinstall the required CLIs and verify dependency connectivity in the target runtime

FAQ

Q: How long do I have to wait after creating an Environment before I can use it? A: A new Environment is immediately usable. The actual container provisioning, including dependency installation, happens when a Session starts. Q: Can I pin package versions? A: pip and npm packages support pinning, such as "pandas==2.1.0" or "typescript@5.0.0". apt packages use the default version from the system repository. Q: How many Environments can I create per account? A: There is no hard limit. Create only what you need and use a naming convention to keep things organized.

Next steps