Introduction
Environment variables provide a centralized way to store values that can be shared across all tests in your project. They are managed through the Test Data section in your workspace and work across both the Stably Web Editor and the Stably SDK.Adding Environment Variables
Set the scope
Select which environment this variable belongs to (e.g.,
staging, production, or All Environments). Variables scoped to a specific environment are only available when tests run in that environment. If you’re unsure, choose All Environments so every test can access it.
Use environment-scoped variables to store values like API keys, base URLs, and configuration that differ between staging and production.
Configure its value
Enter the variable name and value. JSON values are also supported — they will be accessible in your tests as parsed JSON objects.
Set the sensitivity
Toggle Sensitive to encrypt and hide the value after creation.
This will prevent the value from being captured in Playwright traces.

Downloading Variables as .env
You can download all your environment variables as a .env file directly from the dashboard. This makes it easy to sync your variables to your local development environment for use with the Stably SDK.
Click the Download .env button in the Environment Variables section of the Test Data page:

# MY_SECRET - SENSITIVE (value not exported)). Place the file in your project root for local test execution.
Using Environment Variables
Environment variables are accessed viaprocess.env.VARIABLE_NAME in your test code. How they get loaded depends on whether you’re using Stably on the web or locally.
- Stably Web
- Stably SDK (Local)
Environment variables you configure in Test Data are automatically injected into the AI agent’s environment. No additional setup is needed.The AI agent will use You can also reference variables naturally in your AI instructions — the agent knows which environment variables are available and will match them to your intent:
process.env.VARIABLE_NAME in the generated test code:- “Navigate to the base URL”
- “Log in with the test account credentials”
- “Use the API key to authenticate”
Editing and Deleting Variables
To edit a variable, click on it in the variables list to expand the edit form. You can update its name, value, and environment scope. For sensitive variables, you can provide a new value but cannot view the current one. To delete a variable, click the delete icon next to it in the variables list.Best Practices
| ✔️ Do | ❌ Avoid |
|---|---|
| Store secrets and API keys as Sensitive variables. | Hard-coding credentials directly in tests. |
Use descriptive UPPER_SNAKE_CASE names (e.g., API_KEY, BASE_URL). | Abbreviations that will be hard to remember (akp). |
| Create environment-specific variables for different staging environments. | Using the same credentials across all environments. |
| Use environment variables for values shared across multiple tests. | Creating duplicate variables with the same value. |