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 is cmd/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_hosts is left out on create, the environment gets the default list from the user guide (GitHub plus the common package registries).
  • is_default: true clears the flag on the user’s other environments. Setting it on an archived environment answers 409.
Validation errors answer 422 with code VALIDATION_ERROR:

Secrets

Answers the environment object. Values are encrypted at rest with the platform AES-256-GCM credential cipher, the same 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)

Gizzi calls this on the first turn of a cloud session started with an 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

Migration 095_code_environments.sql adds two tables:
  • code_environments: one row per environment, user_id scoped, with a partial unique index that allows one default per user.
  • code_environment_secrets: (environment_id, name) primary key, value_ciphertext and the 12-byte GCM value_nonce, hosts. Rows are deleted with their environment.