# List a machine's environments

Source: https://www.jawsdeploy.net/rest-api/machines-environments-list | Section: Machines

Return the environments one machine is currently assigned to.

`GET /api/machine/environments`

Returns the environments a single machine is assigned to. The same set is visible from the workspace side on [List machines](https://www.jawsdeploy.net/rest-api/machines-list); this endpoint is the cheaper read when you already hold a `machineId` and only want that one machine.

A machine only takes part in a deployment to an environment it is assigned to, so this list is what decides whether a given deployment will reach it.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `machineId` | query | string | yes | ID of the machine, from [List machines](https://www.jawsdeploy.net/rest-api/machines-list). |

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `machineId`. A machine that belongs to another organization is reported the same way as one that does not exist. |
| 401 | Missing or invalid Basic auth credentials, or the service account lacks permission to manage machines in this workspace. |

Example request:

```
GET /api/machine/environments?machineId=mch_web01 HTTP/1.1
Authorization: Basic <base64(...)>
```

Example response:

```
{
  "machineId": "mch_web01",
  "workspaceId": "ws_abc",
  "environments": [
    { "environmentId": "env_stage", "name": "Staging", "enabled": true },
    { "environmentId": "env_prod", "name": "Production", "enabled": true }
  ]
}
```

