Create an environment

Poll GET /v1/environments/{id} until state is running. Each service's status carries its readiness and, when intercepted, which workspace holds it.

POST /v1/environments with a name, a list of services, and a disk quota. The response is the environment in creating; it is running once every service is up.

Request

API
curl -sS https://dev.kloudlite.io/v1/environments \  -H "Authorization: Bearer $KL_TOKEN" -H 'content-type: application/json' \  -d '{    "name": "acme-dev",    "region": "centralindia-k3s",    "quota_gb": 20,    "owner": "acme",    "services": [      {        "name": "db",        "image": "postgres:16",        "command": [],        "env": { "POSTGRES_PASSWORD": "dev" },        "ports": [5432],        "mounts": [{ "folder": "pgdata", "path": "/var/lib/postgresql/data" }]      },      {        "name": "api",        "image": "cr.khost.dev/acme/api:1",        "command": ["node", "server.js"],        "env": { "DATABASE_URL": "postgres://postgres:dev@db:5432/postgres" },        "ports": [8080],        "mounts": []      }    ]  }'
FieldRequiredMeaning
nameyesEnvironment name, unique per owner
servicesyesAt least one — see Services
quota_gbyesDisk for every mount together; default 20
ttl_secsnoDelete the environment this many seconds after it was last used (600 to 2592000); absent means never
ownernoA team slug you belong to; default is you

Response

json
{  "id": "env-2b8c…",  "owner": "acme",  "name": "acme-dev",  "region": "centralindia-k3s",  "state": "creating",  "placement": null,  "services": [ … ],  "restored_to": null}

Poll GET /v1/environments/{id} until state is running. Each service's status carries its readiness and, when intercepted, which workspace holds it.

Errors

StatusWhy
400A service name that is not a DNS label, a mount path that is not absolute, a port of 0, an env key the API server would refuse
409Over quota; the body names the dimension