Scripting API

Atrahasis has a full JavaScript scripting layer built into every place a request or a test runs. You can inspect and mutate outgoing requests before they are sent, parse responses, carry data between steps, read and write environment variables, call external services, and export reports to external systems — all from small, focused scripts written directly inside the app.

The at Object

Every Atrahasis script has access to a single global called at. It groups everything the scripting API exposes into namespaces, one per concern:

  • at.environment — read and write environment variables. Changes are persisted to the active environment.
  • at.flow — read and write short-lived, in-memory variables that pass data between steps. Nothing here is written to disk.
  • at.request — inspect the outgoing HTTP request. Mutate it in pre-scripts, read it in post-scripts.
  • at.response — inspect the HTTP response. Available only in post-scripts.
  • at.export — build a finished flow or load-test report as JSON, HTML, or PDF. Available only in After All scripts, after a real run has produced results.

Where Scripts Run

There are three execution modes, and they determine which parts of the at object are available:

  • Pre-Script: runs just before a request is sent. You can mutate the outgoing URL, headers, and body via at.request. at.response is empty here — the response does not exist yet.
  • Post-Script: runs right after a response is received. at.response is fully populated. at.request is read-only here — any attempt to mutate it is silently ignored.
  • Lifecycle (Before All / After All): runs once per flow or load test, outside the context of any single request. There is no request or response here — at.request and at.response are empty. at.export is available only in the After All variant.

Limits Every Script Shares

Two safety limits apply to every script in Atrahasis, regardless of where it runs:

  • 30-second timeout: if a script does not finish within 30 seconds it is terminated and the script result is reported as a failure.
  • 1000-character console cap: across all console.log, info, warn, and error calls in a single run, the total output is capped at 1000 characters. Once the cap is reached further logs are dropped. In main-engine scripts (standalone, project, flow, and lifecycle) a single [WARN] Log limit reached (1000 chars) line is appended when the cap is first hit; load test step scripts (Boa engine) simply stop appending — no warning line is added.

What This Chapter Covers

The sub-sections below walk through every scripting surface the app exposes, in the order you are likely to meet them:

  • Where scripts live: Contexts, Globals.
  • The at namespaces: at.environment, at.flow, at.request, at.response, at.export.
  • Lifecycle scripts: Before All & After All.
  • Authoring help: Snippets Panel, Variable Resolution.
  • Load test specifics: Load Test Step Limits, Best Practices.