Skip to main content
Environments

Environment schemas

Environment object

Returned by create, get, list, update, and archive endpoints.
FieldTypeDescription
idstringEnvironment ID with the env_ prefix
typestringAlways "environment"
namestringEnvironment name
descriptionstringEnvironment description
configEnvironment configEnvironment configuration
metadataobjectMetadata object. Defaults to {}
archived_atstring | nullArchive time in UTC, or null when not archived
created_atstringCreation time in UTC
updated_atstringLast update time in UTC

Environment config

FieldTypeRequiredDescription
typestringYes"cloud" or "self_hosted"
packagesEnvironment packagesNoPackage declarations associated with the environment
setup_scriptstringNoUser setup script text. See Environment setup script
For self_hosted, the config can contain type and an optional setup_script:
{"type": "self_hosted", "setup_script": "./initialize-worker.sh"}
A self_hosted config supports only type and an optional setup_script.

Environment packages

packages maps package managers to arrays of package spec strings. Requests support apt, npm, and pip. Cloud Environment responses also contain several reserved fields; omitted arrays are returned as [].
KeyTypeDescriptionExample
typestringAlways "packages" in responses"packages"
aptarray of stringDebian/Ubuntu system package declarations["git", "curl", "build-essential"]
npmarray of stringNode.js package declarations["typescript@5.0.0", "eslint"]
piparray of stringPython package declarations["pandas", "PyYAML==6.0.1"]
cargoarray of stringReserved response field; package installation through this field is not currently supported[]
gemarray of stringReserved response field; package installation through this field is not currently supported[]
goarray of stringReserved response field; package installation through this field is not currently supported[]

Environment setup script

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
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. The error response includes the setup_script exit code and a stderr excerpt to help diagnose the failure.
{
  "config": {
    "type": "cloud",
    "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"
  }
}