KeyEnvKeyEnv
API Reference

Environments

Environment management within projects

Environments

Environment management within projects

List environments

GET /api/v1/projects/{projectId}/environments

Returns all environments in a project

Operation ID: listEnvironments · Authentication: Authorization: Bearer <token>

Path parameters

NameTypeRequiredDescription
projectIdstringyesProject UUID or slug (e.g., "my-project")

Responses

StatusDescriptionBody
200List of environmentsobject
401Authentication requiredError
403Insufficient permissionsError
404Resource not foundError

Response body (200)

FieldTypeDescription
environmentsobject[]

Example

curl -X GET "https://api.keyenv.dev/api/v1/projects/{projectId}/environments" \
  -H "Authorization: Bearer $KEYENV_TOKEN"

Create environment

POST /api/v1/projects/{projectId}/environments

Creates a new environment in a project. Can optionally inherit secrets from another environment. Requires team admin role. The name is normalized to a slug (lowercase letters, numbers, hyphens and underscores, e.g. "QA Env" becomes "qa-env") so it is safe in URLs and CLI commands.

Operation ID: createEnvironment · Authentication: Authorization: Bearer <token>

Path parameters

NameTypeRequiredDescription
projectIdstringyesProject UUID or slug (e.g., "my-project")

Request body

application/json (required)

FieldTypeRequiredDescription
namestringyesEnvironment name, normalized to a slug (lowercase letters, numbers, hyphens and underscores)
inherits_fromstring (uuid)noParent environment ID for secret inheritance

Responses

StatusDescriptionBody
201Environment createdEnvironment
400Invalid requestError
401Authentication requiredError
403Insufficient permissionsError
409Resource already existsError
429Plan limit exceededLimitError

Response body (201)

FieldTypeDescription
idstring (uuid)
project_idstring (uuid)
namestring
inherits_fromstring (uuid)
created_atstring (date-time)

Example

curl -X POST "https://api.keyenv.dev/api/v1/projects/{projectId}/environments" \
  -H "Authorization: Bearer $KEYENV_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","inherits_from":"00000000-0000-0000-0000-000000000000"}'

Get environment

GET /api/v1/projects/{projectId}/environments/{environmentId}

Returns environment details

Operation ID: getEnvironment · Authentication: Authorization: Bearer <token>

Path parameters

NameTypeRequiredDescription
projectIdstringyesProject UUID or slug (e.g., "my-project")
environmentIdstringyesEnvironment UUID or name (e.g., "development", "staging", "production")

Responses

StatusDescriptionBody
200Environment detailsEnvironment
401Authentication requiredError
403Insufficient permissionsError
404Resource not foundError

Response body (200)

FieldTypeDescription
idstring (uuid)
project_idstring (uuid)
namestring
inherits_fromstring (uuid)
created_atstring (date-time)

Example

curl -X GET "https://api.keyenv.dev/api/v1/projects/{projectId}/environments/{environmentId}" \
  -H "Authorization: Bearer $KEYENV_TOKEN"

Rename environment

PATCH /api/v1/projects/{projectId}/environments/{environmentId}

Renames a custom environment. Requires team admin role. The new name is normalized to a slug. Default environments (development, staging, production) cannot be renamed. Secrets, permissions and inheritance are kept because they reference the environment ID. Logs an environment.updated audit event.

Operation ID: updateEnvironment · Authentication: Authorization: Bearer <token>

Path parameters

NameTypeRequiredDescription
projectIdstringyesProject UUID or slug (e.g., "my-project")
environmentIdstringyesEnvironment UUID or name (e.g., "development", "staging", "production")

Request body

application/json (required)

FieldTypeRequiredDescription
namestringyesNew name, normalized to a slug (lowercase letters, numbers, hyphens and underscores)

Responses

StatusDescriptionBody
200Environment renamedEnvironment
401Authentication requiredError
403Insufficient permissionsError
404Resource not foundError
409Resource already existsError

Response body (200)

FieldTypeDescription
idstring (uuid)
project_idstring (uuid)
namestring
inherits_fromstring (uuid)
created_atstring (date-time)

Example

curl -X PATCH "https://api.keyenv.dev/api/v1/projects/{projectId}/environments/{environmentId}" \
  -H "Authorization: Bearer $KEYENV_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"string"}'

Delete environment

DELETE /api/v1/projects/{projectId}/environments/{environmentId}

Deletes an environment with its secrets, permissions, overrides and rotation configs. Requires team admin role. Cannot delete default environments (development, staging, production). Returns 409 if other environments inherit from it; change or delete those first.

Operation ID: deleteEnvironment · Authentication: Authorization: Bearer <token>

Path parameters

NameTypeRequiredDescription
projectIdstringyesProject UUID or slug (e.g., "my-project")
environmentIdstringyesEnvironment UUID or name (e.g., "development", "staging", "production")

Responses

StatusDescriptionBody
204Environment deleted
400Invalid requestError
401Authentication requiredError
403Insufficient permissionsError
404Resource not foundError
409Resource already existsError

Example

curl -X DELETE "https://api.keyenv.dev/api/v1/projects/{projectId}/environments/{environmentId}" \
  -H "Authorization: Bearer $KEYENV_TOKEN"

On this page