Environments
Manage different configurations for your flows and load tests using named environments. Switch between dev, staging, and prod with a single flag.
How Environments Work
Group-Level Environments
Each flow folder and spec folder has its own environments.json file. Environments are scoped to their group — a flow folder's environments are independent from a spec folder's environments.
-eUsing Environments
Select an Environment
Use -e / --env to select which environment to use.
# Run a flow with dev environment
atra run flow-folder -f my-flow -e dev
# Run a load test with staging environment
atra run spec-folder -s my-spec -e staging
# Run all flows/specs with prod environment
atra run folder-name -e prod
-e, atra will show an error listing the unresolved variables with a hint to use --env.Variable Types
Environment vs Flow Variables
{{varName}} — Environment Variables
Persistent data configured in the environment panel. Base URLs, API keys, credentials. Accessible via at.environment.get() and at.environment.set() in scripts. Available in both flows and load tests.
{{flow.varName}} — Flow Variables
Temporary data that carries between steps — tokens, IDs, response values. Not persisted. Designed to keep environments clean by separating runtime data from configuration. Accessible via at.flow.get() and at.flow.set() in scripts.
Example: Environment vs Flow Variables
Auth Flow — Why Both Matter
This example shows a typical auth flow where environment variables hold configuration and flow variables carry runtime data between steps.
Environment (persistent config)
{{base_url}} → https://api.example.com
1. beforeAllScript — Register a user
// Create a user with random data
var baseUrl = at.environment.get("base_url");
var username = "{{random.string}}";
var password = "{{random.string}}";
var res = await fetch(baseUrl + "/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password })
});
// Store in flow vars — these change every run
at.flow.set("username", username);
at.flow.set("password", password);
2. Login Step — Use flow variables in body
URL: {{base_url}}/login
Body: {"username": "{{flow.username}}", "password": "{{flow.password}}"}
// Post-script: extract token from response
var data = at.response.json();
at.flow.set("token", data.token);
3. Subsequent Steps — Use token
URL: {{base_url}}/profile
Auth: Bearer {{flow.token}}
{{base_url}} is an environment variable — it stays the same across runs. {{flow.token}} is a flow variable — it changes every run because the user and token are random. Keep configuration in environments, keep runtime data in flow variables.How to Access Variables
Scripts vs Step Inputs
In Scripts (beforeAll, afterAll, pre-script, post-script)
Use the scripting API: at.environment.get() / at.environment.set() and at.flow.get() / at.flow.set()
In Step Inputs (URL, headers, body, params, auth)
Use placeholder syntax: {{varName}} for environment variables and {{flow.varName}} for flow variables
Variable Sources
Where Variables Come From
Each environment variable has a source that determines how its value is resolved.