Skip to main content

List environments

Retrieve the environments within an app.

Use this to enumerate every environment in an app. Identify the app by its project slug and app slug. Results are ordered by environment id. An app has only a handful of environments, so all of them are returned in a single response.

Required Permissions

Your root key must have the following permission:

  • environment.*.read_environment (to read environments in any app)
1 min read
post/v2/environments.listEnvironments
Request example
Response
post/v2/environments.listEnvironments

Authorization

Authorizationstringheaderrequired#

Unkey uses bearer tokens for authentication. Public integrations use root keys, while the dashboard proxy uses short-lived JWTs.
To authenticate, include the token in the Authorization header of each request:

Root keys have specific permissions attached to them, controlling what operations they can perform. Legacy permissions use tuple strings like api.*.create_key; resource permissions use Unkey Resource Names plus actions, like unkey:v1:ws_123:keyspaces/*#create_key.
Security best practices:

  • Keep root keys secure and never expose them in client-side code
  • Use different root keys for different environments
  • Rotate keys periodically, especially after team member departures
  • Create keys with minimal necessary permissions following least privilege principle
  • Monitor key usage with audit logs.

Body

application/json
projectstringrequired#

Identifies a resource by either its unique ID or its slug.
Accepts a prefixed ID (such as 'proj_' or 'app_') or a slug.

Length: 3–255Pattern: ^[a-zA-Z0-9_-]+$

appstringrequired#

Identifies a resource by either its unique ID or its slug.
Accepts a prefixed ID (such as 'proj_' or 'app_') or a slug.

Length: 3–255Pattern: ^[a-zA-Z0-9_-]+$

Responses

application/json
Successfully retrieved the app's environments.
metaobjectrequired#
Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The requestId is particularly important when troubleshooting issues with the Unkey support team.
Show child attributes
requestIdstringrequired#
A unique id for this request. Always include this ID when contacting support about a specific API request. This identifier allows Unkey's support team to trace the exact request through logs and diagnostic systems to provide faster assistance.
dataobject[]required#
Array of environments in the app, ordered by environment id.
Show child attributes
idstringrequired#
The unique identifier of the environment, generated by Unkey.
slugstringrequired#
Human-readable slug of the environment, unique within its app.
descriptionstringrequired#

Human-readable description of this environment.
Empty string if none was provided.

kindenum<string>required#

The deployment lifecycle role of an environment.

  • production: Deployments serve production traffic, support promotion and rollback, and cannot be stopped.
  • preview: Deployments can be stopped and started and are eligible for preview lifecycle automation.
Options:productionpreview
deleteProtectionbooleanrequired#

Whether delete protection is enabled for this environment.
When true, the environment cannot be deleted until protection is disabled.

createdAtintegerrequired#
Unix timestamp in milliseconds when the environment was created.

Range: 0–9223372036854776000

updatedAtinteger#

Unix timestamp in milliseconds when the environment was last updated.
Omitted if the environment has never been updated.

Range: 0–9223372036854776000

runtimeobject#

Runtime settings that control how the container runs.
Omitted until the environment has runtime settings.

Show child attributes
portintegerrequired#
Port the container listens on.
vCpusnumberrequired#
CPU allocation in vCPUs (1 = one vCPU, 0.5 = half a vCPU).
memoryMibintegerrequired#
Memory allocation in mebibytes.
storageMibintegerrequired#
Ephemeral storage allocation in mebibytes.
commandstring[]required#
Container entrypoint command override.
healthcheckobject#
Show child attributes
methodenum<string>required#
HTTP method used to probe the container.
Options:GETPOST
pathstringrequired#
HTTP path probed on the container. Must start with a slash.

Length: 1–512Pattern: ^(/[\w\-]+)+(\.[\w]+)?$

intervalSecondsinteger#
How often the probe runs, in seconds. Defaults to 10 when omitted.

Range: 1–3600

timeoutSecondsinteger#
Per-probe timeout, in seconds. Defaults to 5 when omitted.

Range: 1–3600

failureThresholdinteger#
Consecutive failures before the container is restarted. Defaults to 3 when omitted.

Range: 1–100

initialDelaySecondsinteger#
Delay before the first probe runs, in seconds. Defaults to 0 when omitted.

Range: 0–3600

shutdownSignalenum<string>required#
Signal sent to the container on shutdown.
Options:SIGTERMSIGINTSIGQUITSIGKILL
upstreamProtocolenum<string>required#
Protocol used to reach the container.
Options:http1h2c
openapiSpecPathstring#
Path to the OpenAPI spec served by the container, if any.
buildobject#

Build settings that control how the app is built.
Omitted until the environment has build settings.

Show child attributes
dockerfilestring#
Path to the Dockerfile used to build the app, if any.
rootDirectorystringrequired#
The directory the app is built from. "." for the repository root.
buildCommandstring#

Overrides the build command auto-detected by Railpack, so monorepos can
scope the build to a single app. Omitted when left to auto-detection or
for Dockerfile builds.

watchPathsstring[]required#
Paths that trigger a rebuild when changed.
autoDeploybooleanrequired#
Whether pushes automatically trigger a deployment.
regionsobject[]#

Per-region deployment settings for this environment.
Empty until regional settings are configured.

Show child attributes
namestringrequired#
Region name, such as us-east-1.

Length: 1–64

replicasobjectrequired#
Min and max replica bounds for autoscaling in a region.
Show child attributes
minintegerrequired#
Minimum number of replicas.
maxintegerrequired#
Maximum number of replicas.