
# List your environments for the CLI

`GET https://api.keenauth.com/v1/environments` · called by `keenauth env list`

Lists the environments you can work on with the CLI: the environments of the account you signed in to with `keenauth login` in which you have a dashboard role, through an account, project or environment assignment. Deleted environments and environments of deleted projects are not listed. You do not call this endpoint yourself; `keenauth env list` shows the list and `keenauth env use <environment_id>` picks one.

If you are a member of more than one account, the list holds the environments of the account of your current sign-in only; sign in to the other account to see its environments. If you have no role in any environment, the list is empty.

## Request

Headers:

| Header | Required | Description |
| --- | --- | --- |
| `Authorization` | yes | `DPoP <access token>`: the access token the CLI received when you signed in. |
| `DPoP` | yes | A DPoP proof for this request (`htm` `GET`, `htu` `https://api.keenauth.com/v1/environments` without the query), signed with the key the access token is bound to; it carries the hash of the access token and the server nonce. |

Query parameters:

| Parameter | Description |
| --- | --- |
| `limit` | Page size, 1 to 100; default 20. |
| `after` | The `list_metadata.after` value of the previous page. |

The list pages forward only: `before` and `order` are refused with `validation_failed`.

## Response

`200 OK` with `Cache-Control: no-store`, newest environment first:

| Field | Description |
| --- | --- |
| `data[].id` | The environment (`env_…`); use it with `keenauth env use` and the management token request. |
| `data[].slug` | The environment's DNS label (`<slug>.<region>.keenauth.app`). |
| `data[].display_name` | The environment's name. |
| `data[].environment_type` | `production`, `staging` or `development`. |
| `data[].region` | The region of the environment's data, for example `eu`. |
| `data[].project_id` | The project (`proj_…`). |
| `data[].project_name` | The project's name. |
| `data[].account_id` | The account (`acct_…`). |
| `data[].dashboard_role` | Your dashboard role in the environment (`owner`, `admin`, `developer`, `support`, `billing`, `viewer`, or `custom` when only custom roles cover it). |
| `data[].created_at` | When the environment was created (RFC 3339, UTC). |
| `list_metadata.after` | Cursor of the next page; `null` on the last page. |
| `list_metadata.before` | Always `null`. |

The cursor is bound to you and to the account; it does not work for another user or another sign-in.

## Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_cursor` | The `after` cursor is malformed, altered or was issued for another user or account. |
| 401 | `unauthenticated` | No access token was sent. |
| 401 | `invalid_token` | The access token is invalid, expired or not the CLI's; sign in again with `keenauth login`. |
| 401 | `invalid_dpop_proof` | The DPoP proof is missing, repeated or does not match the request or the token's key. |
| 401 | `use_dpop_nonce` | Retry with a proof that carries the nonce of the `DPoP-Nonce` response header. |
| 401 | `insufficient_user_authentication` | Multi-factor authentication is required; sign in again. |
| 422 | `validation_failed` | `limit` is not an integer from 1 to 100, a parameter is repeated, or `before` or `order` was sent. |

## Example

```bash
curl "https://api.keenauth.com/v1/environments?limit=50" \
  -H "Authorization: DPoP $ACCESS_TOKEN" \
  -H "DPoP: $DPOP_PROOF"
```
