codai Projects & Environments API
Cloud Environments control plane. A **project** groups environments (repository, default branch, devcontainer path, isolation mode); an **environment** is one machine reachable through the relay via the `codaid` daemon. Members, forwarded ports, sealed secrets and an append-only event log hang off the environment. Visibility: you see a project if you own it or belong to its org; you see an environment if you own it, are a member of it, or belong to its org. Unknown or foreign ids always answer 404 (never 403) so ids cannot be enumerated; a role violation on a resource you CAN see answers 403. Environment roles: `owner` ≥ `maintainer` ≥ `developer` ≥ `viewer` — the environment owner and org owners/admins act as `owner`. Isolation `vm_per_dev` pins one live environment per developer (`for_user_id`): creating a second one answers 409 `already_has_env` carrying the `environment_id` to reuse, and such environments have exactly one member (409 `vm_per_dev_single_member`). Every mutation appends an `environment_events` row. Managed providers (`openstack`, `hetzner`, `local`) are feature-gated (403 until enabled for the key); `byo` — bring your own machine — is open to every key. Project and environment rows are returned camelCase (as stored); request bodies and member/secret lists are snake_case, mirrored here exactly as the gateway sends them. Live daemon state (online, activity, listening ports, git state, attached clients, locks) is served by the **relay**, not the gateway: `GET https://relay.codai.ro/v1/environments/{id}/status`, same bearer key, same 404 rule. It is modelled as the `RelayEnvironmentStatus` path item under `components.pathItems` because it lives on a different host.