> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hopx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Environment variable management resource for configuring sandbox environment in HopX using the JavaScript/TypeScript SDK. Complete reference for the Environment class including async methods for getting, setting, updating, and clearing environment variables. Includes TypeScript examples for configuration management.

**Version:** 0.1.22\
**Last Verified:** 2025-01-27\
**Package:** `@hopx-ai/sdk` on [npm](https://www.npmjs.com/package/@hopx-ai/sdk)

## Overview

The `EnvironmentVariables` resource (accessed via `sandbox.env`) provides methods for managing environment variables in sandboxes.

## Methods

### `getAll`

Get all environment variables.

```typescript theme={null}
async env.getAll(): Promise<Record<string, string>>
```

**Returns:** `Promise<Record<string, string>>` - Dictionary of all environment variables

***

### `get`

Get specific environment variable.

```typescript theme={null}
async env.get(key: string): Promise<string | undefined>
```

**Returns:** `Promise<string | undefined>` - Variable value or `undefined`

***

### `set`

Set a single environment variable.

```typescript theme={null}
async env.set(key: string, value: string): Promise<void>
```

***

### `setAll`

Replace all environment variables (destructive).

```typescript theme={null}
async env.setAll(envVars: Record<string, string>): Promise<Record<string, string>>
```

<Warning>
  This replaces ALL existing environment variables. Use `update()` to merge instead.
</Warning>

***

### `update`

Update environment variables (merge with existing).

```typescript theme={null}
async env.update(envVars: Record<string, string>): Promise<Record<string, string>>
```

***

### `delete`

Delete a single environment variable.

```typescript theme={null}
async env.delete(key: string): Promise<void>
```

***

## Related Classes

* **[Sandbox](/sdk/javascript/sandbox)** - Main sandbox class
* **[Commands](/sdk/javascript/commands)** - Command execution resource

## See Also

* [Core Concepts: Environment Variables](/core-concepts/environment-variables) - Learn about environment configuration
* [Sandbox Class](/sdk/javascript/sandbox) - Access env via `sandbox.env`

## Related

* **[Python SDK: Environment Variables](/sdk/python/environment-variables)** - Python SDK environment management
* **[Getting Environment Variables](/core-concepts/environment/getting)** - Learn about getting env vars
* **[Setting Environment Variables](/core-concepts/environment/setting)** - Learn about setting env vars

## Next Steps

* Learn about [Getting Environment Variables](/core-concepts/environment/getting) to read values
* Explore [Setting Environment Variables](/core-concepts/environment/setting) to configure environment
* Review [Updating Environment Variables](/core-concepts/environment/updating) for batch updates
* **[CLI Environment Variables](/cli/commands/env)** - Manage env vars from CLI
