Skip to main content

Environments API

Each vault has a list of environments (e.g., local, dev, staging, production). Secrets are scoped to environments.

List environments

GET /v1/vaults/:owner/:repo/environments
Authorization: Bearer <token>

Response:

{
"data": {
"environments": ["local", "dev", "staging", "production"]
}
}

New vaults start with default environments: local, dev, staging, production.


Create environment

Requires admin access on the repository.

POST /v1/vaults/:owner/:repo/environments
Authorization: Bearer <token>
Content-Type: application/json

{
"name": "preview"
}

Validation:

  • 2-30 characters
  • Lowercase letters, numbers, dashes, underscores
  • Must start with a letter
  • Must not already exist

Response (201 Created):

{
"data": {
"environment": "preview",
"environments": ["dev", "local", "preview", "production", "staging"]
}
}

Errors:

StatusReason
400Invalid environment name
403Not an admin on this repository
409Environment already exists

Rename environment

Requires admin access. All secrets in the environment are updated.

PATCH /v1/vaults/:owner/:repo/environments/:name
Authorization: Bearer <token>
Content-Type: application/json

{
"newName": "development"
}

Response:

{
"data": {
"oldName": "dev",
"newName": "development",
"environments": ["development", "local", "production", "staging"]
}
}

Delete environment

Requires admin access. Deletes all secrets in the environment.

DELETE /v1/vaults/:owner/:repo/environments/:name
Authorization: Bearer <token>

Response:

{
"data": {
"deleted": "preview",
"environments": ["dev", "local", "production", "staging"]
}
}

Errors:

StatusReason
403Cannot delete the last environment
404Environment not found
warning

Deleting an environment permanently removes all secrets in that environment.