Environments

List Environments

GET
/environments

Returns the environments the caller may view, filtered by any combination of the supported query parameters - organization, project, name, drift status, tags, active and destroyed state, workspace name, and free-text search. Results are paginated with limit (maximum and default 100) and offset, so a large fleet must be read page by page. Use excludeFields to omit expensive fields such as the latest deployment log.

Authorization

env0_API_Key
AuthorizationBasic <token>

env zero API authentication is done via API keys. An API Key can either be created by an organization administrator, in which case it will not be connected to any specific user, or via Personal API Keys to authenticate as a user.

Creating an API Key with a Specific Role

  • Once you've created your organization, you can set up and manage API Keys.
  • Navigate to the Organization Settings page and click the API Keys tab.
  • Click Add API Key and enter a name for your key in the Name field. This name is for reference purposes only and isn't used directly in authentication.

❗️Save Your API Key ID and secret The secret will not be available after you close this window.

Creating a Personal API Key

  • Click on your avatar (located on the top right of the screen)
  • Click on Personal Settings
  • Select the API Keys tab
  • Click Add API Key, and enter a name for your key in the Name field. This name is for reference purposes and isn't used directly in authentication.

❗️Save your API Key ID & secret The secret will not be available after you close this window.

Using an API Key to Authenticate

Authentication of the env zero API is done using the Basic Authentication method. Each request made should include the API Key ID as the username, and the API Key secret as the password. For example, when using curl, we can include these parameters via flag --user {API Key ID}:{API Key Secret}.

API Key Permissions

When creating an API key through the organization settings, you will need to choose if you’d like to grant it Organization Admin or User permissions. In case of the latter, you can assign fine-grained permissions per project. Personal API Keys can be created through the user’s profile page and will have the same permissions as the user has.

Rate Limits

env zero API allows up to 1K requests per 60 seconds, requests are aggregated by IP, HTTP Method and URI. If you exceed this limit, you will receive a 429 status code.

In: header

Query Parameters

limit?string

Number of environments per page. The maximum is 100, with the default value is set to maximum

offset?string

The offset of the first environment returned. Defaults to 0

excludeFields?string

Comma-separated list of fields to exclude from the response (e.g., 'latestDeploymentLog.output,latestDeploymentLog.plan')

driftStatus?string

Comma-separated list of drift statuses to filter by (ERROR, DRIFTED, OK, NEVER_RUN, DISABLED)

tags?string

Comma-separated list of tags to filter by, ANDed together. Each item is either a bare key (matches any value) or 'key=value' (e.g. 'team=eng,cost-center')

isDestroyed?string

Splits the isActive=false set. 'true' returns environments env0 destroyed, 'false' returns environments marked inactive whose resources may still exist. May be sent only with isActive=false; omit to get both

organizationId?string
projectId?string
onlyMy?string
isActive?string
name?string
isRemoteBackend?string
workspaceName?string
workspaceNamePrefix?string
includeSubEnvironments?string
searchText?string

Response Body

application/json

application/json

application/json

curl -X GET "https://example.com/environments"
[  {    "id": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "name": "string",    "organizationId": "string",    "projectId": "string",    "userId": "string",    "workspaceName": "string",    "user": {      "email": "string",      "user_id": "string",      "username": "string",      "created_at": "string",      "updated_at": "string",      "app_metadata": {        "organizations": [          {            "id": "string",            "role": "string",            "name": "string"          }        ],        "isApiKey": true,        "isAutogeneratedTerraformDeployer": true,        "apiKeyType": "oidc",        "createdBy": "string",        "organizationId": "string",        "isSystemUser": true,        "readOnly": true      },      "picture": "string",      "name": "string",      "last_login": "string",      "given_name": "string",      "family_name": "string",      "blocked": true    },    "requiresApproval": true,    "status": "CREATED",    "latestDeploymentLogId": "string",    "latestDeploymentLog": {      "id": "string",      "createdAt": "2019-08-24T14:15:22Z",      "updatedAt": "2019-08-24T14:15:22Z",      "type": "deploy",      "startedBy": "string",      "queuedAt": "2019-08-24T14:15:22Z",      "startedAt": "2019-08-24T14:15:22Z",      "finishedAt": "2019-08-24T14:15:22Z",      "output": {        "property1": {          "value": null,          "sensitive": true,          "type": "string"        },        "property2": {          "value": null,          "sensitive": true,          "type": "string"        }      },      "error": {},      "failedCommand": "string",      "stoppedByTimeoutReason": "DEPLOYMENT_TIME_LIMIT_EXCEEDED",      "customEnv0EnvironmentVariables": {        "environmentId": "string",        "organizationName": "string",        "environmentUrl": "string",        "projectId": "string",        "projectName": "string",        "parentProjectIds": "string",        "parentProjectPath": "string",        "deploymentLogId": "string",        "deploymentType": "deploy",        "deploymentRevision": "string",        "workspaceName": "string",        "rootDir": "string",        "organizationId": "string",        "templateId": "string",        "templateDir": "string",        "templateName": "string",        "environmentName": "string",        "environmentCreatorName": "string",        "environmentCreatorUserId": "string",        "environmentCreatorEmail": "string",        "deployerName": "string",        "deployerUserId": "string",        "deployerEmail": "string",        "reviewerName": "string",        "reviewerEmail": "string",        "reviewerUserId": "string",        "vcsProvider": "gitlab",        "prAuthor": "string",        "prNumber": "string",        "prSourceRepository": "string",        "prSourceBranch": "string",        "prTargetBranch": "string",        "commitHash": "string",        "commitUrl": "string",        "oidcToken": "string",        "vcsAccessToken": "string",        "tfPlanJson": "string",        "cliArgsPlan": "string",        "cliArgsApply": "string",        "discoveryRepositoryUrl": "string",        "discoveryPrNumber": "string",        "discoveryVCS": "gitlab"      },      "costEstimation": {        "totalMonthlyCost": 0,        "monthlyCostDiff": 0,        "projects": [          {            "diff": {              "totalMonthlyCost": "string"            }          }        ]      },      "status": "IN_PROGRESS",      "blueprintId": "string",      "blueprintName": "string",      "blueprintRepository": "string",      "blueprintRevision": "string",      "blueprintPath": "string",      "blueprintType": "opentofu",      "comment": "string",      "environmentId": "string",      "resourceCount": 0,      "resources": [        {          "provider": "string",          "type": "string",          "name": "string",          "moduleName": "string",          "mode": "managed"        }      ],      "startedByUser": {        "email": "string",        "user_id": "string",        "username": "string",        "created_at": "string",        "updated_at": "string",        "app_metadata": {          "organizations": [            {              "id": "string",              "role": "string",              "name": "string"            }          ],          "isApiKey": true,          "isAutogeneratedTerraformDeployer": true,          "apiKeyType": "oidc",          "createdBy": "string",          "organizationId": "string",          "isSystemUser": true,          "readOnly": true        },        "picture": "string",        "name": "string",        "last_login": "string",        "given_name": "string",        "family_name": "string",        "blocked": true      },      "isScheduledRun": true,      "abortedBy": "string",      "abortedByUser": {        "email": "string",        "user_id": "string",        "username": "string",        "created_at": "string",        "updated_at": "string",        "app_metadata": {          "organizations": [            {              "id": "string",              "role": "string",              "name": "string"            }          ],          "isApiKey": true,          "isAutogeneratedTerraformDeployer": true,          "apiKeyType": "oidc",          "createdBy": "string",          "organizationId": "string",          "isSystemUser": true,          "readOnly": true        },        "picture": "string",        "name": "string",        "last_login": "string",        "given_name": "string",        "family_name": "string",        "blocked": true      },      "gitUser": "string",      "gitAvatarUrl": "string",      "prNumber": "string",      "triggerName": "user",      "driftDetected": true,      "plan": {        "resourceChanges": [          {            "id": "string",            "cloudId": "string",            "moduleName": "string",            "driftByCloud": true,            "name": "string",            "providerName": "string",            "type": "string",            "path": "string",            "action": "create",            "attributes": [              {                "name": "string",                "before": null,                "after": null              }            ],            "importing": {              "id": "string"            },            "actionReason": "replace_because_tainted",            "createBeforeDestroy": true,            "previousAddress": "string"          }        ],        "outputChanges": [          {            "moduleName": "string",            "name": "string",            "action": "create",            "attributes": [              {                "name": "string",                "before": null,                "after": null              }            ]          }        ]      },      "planSummary": {        "added": 0,        "changed": 0,        "destroyed": 0,        "imported": 0      },      "isSkippedApply": true,      "workflowDeploymentId": "string",      "workflowFile": {        "settings": {          "environmentRemovalStrategy": "destroy"        },        "environments": {          "property1": {            "environmentId": "string",            "toDestroy": true,            "isRemoteBackend": true,            "k8sNamespace": "string",            "vcs": {              "type": "opentofu",              "tokenName": "string",              "tokenId": "string",              "sshKeys": [                {                  "id": "string",                  "name": "string"                }              ],              "githubInstallationId": 0,              "bitbucketClientKey": "string",              "isBitbucketServer": true,              "isGitLabEnterprise": true,              "isGitHubEnterprise": true,              "isGitLab": true,              "isAzureDevOps": true,              "isHelmRepository": true,              "vcsConnectionId": "string",              "repository": "string",              "revision": "string",              "path": "string",              "fileName": "string",              "helmChartName": "string",              "terraformVersion": "string",              "opentofuVersion": "string",              "terragruntVersion": "string",              "terragruntTfBinary": "terraform",              "pulumiVersion": "string",              "ansibleVersion": "string"            },            "name": "string",            "templateName": "string",            "templateId": "string",            "templateType": "opentofu",            "revision": "string",            "workspace": "string",            "needs": [              "string"            ],            "terragruntWorkingDirectory": "string",            "requiresApproval": true,            "disabled": "string"          },          "property2": {            "environmentId": "string",            "toDestroy": true,            "isRemoteBackend": true,            "k8sNamespace": "string",            "vcs": {              "type": "opentofu",              "tokenName": "string",              "tokenId": "string",              "sshKeys": [                {                  "id": "string",                  "name": "string"                }              ],              "githubInstallationId": 0,              "bitbucketClientKey": "string",              "isBitbucketServer": true,              "isGitLabEnterprise": true,              "isGitHubEnterprise": true,              "isGitLab": true,              "isAzureDevOps": true,              "isHelmRepository": true,              "vcsConnectionId": "string",              "repository": "string",              "revision": "string",              "path": "string",              "fileName": "string",              "helmChartName": "string",              "terraformVersion": "string",              "opentofuVersion": "string",              "terragruntVersion": "string",              "terragruntTfBinary": "terraform",              "pulumiVersion": "string",              "ansibleVersion": "string"            },            "name": "string",            "templateName": "string",            "templateId": "string",            "templateType": "opentofu",            "revision": "string",            "workspace": "string",            "needs": [              "string"            ],            "terragruntWorkingDirectory": "string",            "requiresApproval": true,            "disabled": "string"          }        }      },      "workflowDeploymentOptions": {        "node": "string",        "operation": "run-from-here"      },      "stateVersionId": "string",      "reviewersUsers": [        {          "user": {            "email": "string",            "user_id": "string",            "username": "string",            "created_at": "string",            "updated_at": "string",            "app_metadata": {              "organizations": [                {                  "id": "string",                  "role": "string",                  "name": "string"                }              ],              "isApiKey": true,              "isAutogeneratedTerraformDeployer": true,              "apiKeyType": "oidc",              "createdBy": "string",              "organizationId": "string",              "isSystemUser": true,              "readOnly": true            },            "picture": "string",            "name": "string",            "last_login": "string",            "given_name": "string",            "family_name": "string",            "blocked": true          },          "action": "approved"        }      ],      "reviewers": [        {          "userId": "string",          "action": "approved"        }      ],      "reviewedBy": "string",      "reviewedByUser": {        "email": "string",        "user_id": "string",        "username": "string",        "created_at": "string",        "updated_at": "string",        "app_metadata": {          "organizations": [            {              "id": "string",              "role": "string",              "name": "string"            }          ],          "isApiKey": true,          "isAutogeneratedTerraformDeployer": true,          "apiKeyType": "oidc",          "createdBy": "string",          "organizationId": "string",          "isSystemUser": true,          "readOnly": true        },        "picture": "string",        "name": "string",        "last_login": "string",        "given_name": "string",        "family_name": "string",        "blocked": true      },      "targets": [        "string"      ],      "variables": [        {          "id": "string",          "name": "string",          "scope": "SET",          "scopeId": "string",          "value": "string",          "isSensitive": true,          "type": 0,          "schema": {            "type": "string",            "enum": [              "string"            ],            "format": "HCL"          },          "userId": "string",          "updatedAt": "2019-08-24T14:15:22Z",          "projectId": "string"        }      ],      "gitMetadata": {        "commit": "string",        "branch": "string",        "timestamp": "2019-08-24T14:15:22Z"      },      "providerVersions": {        "property1": "string",        "property2": "string"      },      "moduleVersions": {        "property1": "string",        "property2": "string"      },      "stateFileHash": {        "value": "string"      },      "driftCause": {        "unappliedCommits": [          {            "userEmail": "string",            "timestamp": "2019-08-24T14:15:22Z",            "commitHash": "string"          }        ]      }    },    "lifespanEndAt": "2019-08-24T14:15:22Z",    "markedForAutoDestroy": 0,    "isArchived": true,    "nextScheduledDates": {      "deploy": "2019-08-24T14:15:22Z",      "destroy": "2019-08-24T14:15:22Z"    },    "vcsCommandsAlias": "string",    "vcsPrCommentsEnabled": true,    "continuousDeployment": true,    "pullRequestPlanDeployments": true,    "autoDeployOnPathChangesOnly": true,    "autoDeployByCustomGlob": "string",    "terragruntWorkingDirectory": "string",    "isSingleUseBlueprint": true,    "workflowEnvironmentId": "string",    "isRemoteBackend": true,    "isLocked": true,    "lockStatus": {      "reason": "string",      "updatedBy": "string",      "updatedByUser": {        "email": "string",        "user_id": "string",        "username": "string",        "created_at": "string",        "updated_at": "string",        "app_metadata": {          "organizations": [            {              "id": "string",              "role": "string",              "name": "string"            }          ],          "isApiKey": true,          "isAutogeneratedTerraformDeployer": true,          "apiKeyType": "oidc",          "createdBy": "string",          "organizationId": "string",          "isSystemUser": true,          "readOnly": true        },        "picture": "string",        "name": "string",        "last_login": "string",        "given_name": "string",        "family_name": "string",        "blocked": true      },      "updatedAt": "2019-08-24T14:15:22Z"    },    "k8sNamespace": "string",    "isRemoteApplyEnabled": true,    "driftStatus": "ERROR",    "tags": {      "property1": [        "string"      ],      "property2": [        "string"      ]    }  }]