# List environments

Source: https://www.jawsdeploy.net/rest-api/environments-list | Section: Environments

List the deployment environments in a workspace, and whether each one is accepting deployments.

`GET /api/environment`

Returns the workspace's environments with their sort order, display colour and whether each one is currently accepting deployments.

This is the endpoint that answers *why* a deploy was refused for an environment: `enabled` being `false` means it was switched off with [Update an environment](https://www.jawsdeploy.net/rest-api/environments-update), as opposed to being blocked by lifecycle phase progression, which the deploy error alone does not distinguish.

Deleted environments are not returned.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `workspaceId` | query | string | yes | ID of the workspace. |

## Response fields

| Field | Type | Description |
|---|---|---|
| `workspaceId` | string | The workspace the environments belong to, echoing the one you asked for. |
| `environments` | object[] | The workspace's environments. Empty array when it has none - not an error. |
| `environments[].environmentId` | string | The environment's id. This is the value every other endpoint takes as `environmentId`. |
| `environments[].name` | string | Display name, unique within the workspace. |
| `environments[].sortOrder` | integer | Display order in the UI. Not a deployment order. |
| `environments[].color` | string | Hex colour of the environment chip, or `null` when none is set. |
| `environments[].enabled` | boolean | `false` when the environment has been switched off and will refuse deployments. See [Update an environment](https://www.jawsdeploy.net/rest-api/environments-update). |

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `workspaceId`. |
| 401 | Missing or invalid Basic auth credentials, or the service account lacks the required role. |

Example request:

```
GET /api/environment?workspaceId=ws_abc
```

Example response:

```
{
  "workspaceId": "ws_abc",
  "environments": [
    {
      "environmentId": "env_a",
      "name": "Production",
      "sortOrder": 30,
      "color": "#ff6b6b",
      "enabled": true
    },
    {
      "environmentId": "env_b",
      "name": "Staging",
      "sortOrder": 20,
      "color": "#ffb454",
      "enabled": false
    }
  ]
}
```

