# REST Resource: users.environments

- [Resource: Environment](https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments#Environment)
  - [JSON representation](https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments#Environment.SCHEMA_REPRESENTATION)
- [State](https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments#State)
- [Methods](https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments#METHODS_SUMMARY)

## Resource: Environment

A Cloud Shell environment, which is defined as the combination of a Docker image specifying what is installed on the environment and a home directory containing the user's data that will remain across sessions. Each user has at least an environment with the ID "default".

| JSON representation |
|---|
| ``` { "name": string, "id": string, "dockerImage": string, "state": enum (`https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments#State`), "webHost": string, "sshUsername": string, "sshHost": string, "sshPort": integer, "publicKeys": [ string ] } ``` |

| Fields ||
|---|---|
| `name` | `string` Immutable. Full name of this resource, in the format `users/{owner_email}/environments/{environmentId}`. `{owner_email}` is the email address of the user to whom this environment belongs, and `{environmentId}` is the identifier of this environment. For example, `users/someone@example.com/environments/default`. |
| `id` | `string` Output only. The environment's identifier, unique among the user's environments. |
| `dockerImage` | `string` Required. Immutable. Full path to the Docker image used to run this environment, e.g. "gcr.io/dev-con/cloud-devshell:latest". |
| `state` | ``enum (`https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments#State`)`` Output only. Current execution state of this environment. |
| `webHost` | `string` Output only. Host to which clients can connect to initiate HTTPS or WSS connections with the environment. |
| `sshUsername` | `string` Output only. Username that clients should use when initiating SSH sessions with the environment. |
| `sshHost` | `string` Output only. Host to which clients can connect to initiate SSH sessions with the environment. |
| `sshPort` | `integer` Output only. Port to which clients can connect to initiate SSH sessions with the environment. |
| `publicKeys[]` | `string` Output only. Public keys associated with the environment. Clients can connect to this environment via SSH only if they possess a private key corresponding to at least one of these public keys. Keys can be added to or removed from the environment using the environments.addPublicKey and environments.removePublicKey methods. |

## State

Possible execution states for an environment.

| Enums ||
|---|---|
| `STATE_UNSPECIFIED` | The environment's states is unknown. |
| `SUSPENDED` | The environment is not running and can't be connected to. Starting the environment will transition it to the PENDING state. |
| `PENDING` | The environment is being started but is not yet ready to accept connections. |
| `RUNNING` | The environment is running and ready to accept connections. It will automatically transition back to DISABLED after a period of inactivity or if another environment is started. |
| `DELETING` | The environment is being deleted and can't be connected to. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments/addPublicKey` | Adds a public SSH key to an environment, allowing clients with the corresponding private key to connect to that environment via SSH. |
| ### `https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments/authorize` | Sends OAuth credentials to a running environment on behalf of a user. |
| ### `https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments/get` | Gets an environment. |
| ### `https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments/removePublicKey` | Removes a public SSH key from an environment. |
| ### `https://docs.cloud.google.com/shell/docs/reference/rest/v1/users.environments/start` | Starts an existing environment, allowing clients to connect to it. |