Skip to main content
Retrieve environment variables from your sandbox. You can get all variables at once or fetch specific variables by name.

Overview

Getting environment variables is useful for:
  • Inspecting current environment configuration
  • Verifying variables are set correctly
  • Accessing system and custom variables
  • Debugging environment-related issues
Environment variables include both system variables (like PATH, HOME) and custom variables you’ve set. Sensitive values may be masked in responses.

Get All Environment Variables

Retrieve all environment variables:

Get Specific Variable

Get a single environment variable:

List All Variables

Iterate through all environment variables:

Filter Variables

Filter environment variables by prefix or pattern:

Check Variable Existence

Check if a variable exists:

Verify Variables in Code

Verify environment variables are accessible in code execution:

Complete Example

Here’s a complete example showing environment variable retrieval:

Best Practices

1

1. Use get() for Single Variables

Use env.get(key) for retrieving individual variables with optional defaults.
2

2. Use get_all() for Multiple Variables

Use env.get_all() when you need to access multiple variables or iterate through all.
3

3. Handle Missing Variables

Always check if variables exist or provide defaults when retrieving.
4

4. Mask Sensitive Values

When displaying environment variables, mask sensitive values (keys, secrets, passwords, tokens).
5

5. Verify in Code

Test that environment variables are accessible in code execution to ensure they’re set correctly.

Next Steps