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
1
Navigate to Test Data
Go to Test Data → Variables in your workspace.
2
Add variable
Click + Add Variable to create a new environment variable.
3
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.
4
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.
5
Set the sensitivity
Toggle Sensitive to encrypt and hide the value after creation.
This will prevent the value from being captured in Playwright traces.
6
Save the variable
Save the variable to make it available across all of your tests.

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 CLI
- Manual Setup
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”