at.flow

The at.flow namespace is the short-term memory that connects steps together. Unlike at.environment, nothing here is written to disk. Flow variables live in memory only, for as long as the flow or load test is running, and disappear when the run ends.

The name can be confusing: at.flowis not the Flow Runner module. It is an in-memory key-value store that is available inside both Flow Runner execution and Load Test execution. The Flow Runner module is one of the places where it is useful; load tests are the other.

Three Methods

  • at.flow.get(key): returns the stored value, or undefined if the key does not exist.
  • at.flow.set(key, value): writes a flow variable for the rest of the current iteration.
  • at.flow.has(key): returns true if the key has been set.

Using Flow Variables in Request Fields

Variables stored via at.flow.set()are referenced with {{flow.varName}}syntax and are injected into subsequent steps at request-build time:

  • URL: {{base_url}}/users/{{flow.userId}}
  • Headers: Authorization: Bearer {{flow.token}}
  • Request body: {"user":"{{flow.userId}}"}
  • Assertion expected values: expected: {{flow.expectedId}}

Flow Variables vs. Environment Variables

The two stores look almost identical, with the same shape of get / set / has methods, but they are meant for very different things:

  • Lifetime: environment variables are persisted to disk and survive app restarts. Flow variables live only for the duration of a single run and are cleared when the run ends.
  • Placeholder syntax: environment variables are {{varName}}, flow variables are {{flow.varName}}.
  • Use case: environment is for secrets, base URLs, and long-lived configuration. Flow is for step-to-step handoff: a token extracted in step 1 that step 2 needs, a newly-created user ID that step 3 must delete, a dynamic assertion target computed in a pre-script.

When at.flow Is Available

Flow variables only make sense when there is a run to carry them. Calling any at.flow method from a script that is not running inside a flow or load test throws:

Error: at.flow is only available inside flow execution

In practice, this means:

  • Standalone HTTP request (Box tab): at.flow throws. Use at.environment instead if you need to persist something.
  • Project request run standalone: same again, at.flow throws.
  • Flow step / Flow Before All / Flow After All: at.flow works. Variables set in one step are visible in every later step of the same iteration.
  • Load test step / Load Test Before All / Load Test After All: at.flow works. Each virtual user sees its own independent flow store.

Example: Three-Step Flow

A flow with Create User → Get User → Delete User steps:

Step 1: Create User (post-script)
const data = at.response.json();
at.flow.set("userId", String(data.id));
at.flow.set("username", data.username);
Step 2: Get User
URL: {{base_url}}/api/users/{{flow.userId}}
Assertion: body.username equals {{flow.username}}
Step 3: Delete User
URL: {{base_url}}/api/users/{{flow.userId}}