Overview
A code environment is a per-user recipe that a cloud Code session starts in. The user guide is Cloud environments. The machine-readable spec iscmd/allternit-cloud-api/openapi/code-environments.yaml.
Served by the cloud API at https://api.allternit.com.
User auth is a Clerk session JWT, an Allternit API key (
alt_…, created under ACI › Operator keys; legacy allternit_* tokens still work) with the compute scope, or a runtime device token (Bearer allternit_runtime_…) acting as its owner. Every row is scoped to the caller. Another user’s environment id answers 404.
The environment object
secrets lists names, hosts and created times only. No route but resolve returns a value.
Create and update
POST takes name (required) and any of network_access, allowed_hosts, setup_script, env_vars, repos, is_default. PATCH takes any subset; omitted fields stay as they are. Unknown fields are rejected.
- When
allowed_hostsis left out on create, the environment gets the default list from the user guide (GitHub plus the common package registries). is_default: trueclears the flag on the user’s other environments. Setting it on an archived environment answers409.
422 with code VALIDATION_ERROR:
Secrets
ALLTERNIT_CREDENTIALS_KEY that protects provider tokens and bring-your-own inference keys. When that key isn’t configured, the secret routes and resolve answer 503 with {"error":"code_environment_secrets_not_configured"}. The rest of the API keeps working.
Resolve (runtime only)
environmentId, then clones the repos, writes the env vars, runs the setup script and starts the agent. Only a runtime device token is accepted (a Clerk session or API token answers 401), and only for a device owned by the environment’s user (others answer 404). Archived environments still resolve so a session started just before an archive can finish setting up. Secret values are never written to logs.
Storage
Migration095_code_environments.sql adds two tables:
code_environments: one row per environment,user_idscoped, with a partial unique index that allows one default per user.code_environment_secrets:(environment_id, name)primary key,value_ciphertextand the 12-byte GCMvalue_nonce,hosts. Rows are deleted with their environment.