Skip to content

Multiple scripts

Each collection and request can define multiple scripts per request stage — an ordered list of up to 64 pre-request stage scripts and up to 64 post-request stage scripts. Use separate scripts to break setup and teardown into modular steps, toggle individual steps on and off, or mix inline code with shared snippets.

Within a request stage (collection or request scope), scripts run in a fixed order based on each script's Stage:

StageWhen it runs
Before allOnce, before every other script in the list
Before eachBefore every Main script
MainMain script step (default)
After eachAfter every Main script
After allOnce, after every other script in the list

The script list editor groups scripts into three sections — Before, Main, and After — matching those stages. Section headings appear only when scripts span two or more sections; a single-section list stays flat. Drag to reorder inside a section only. When you click Add, HarborClient asks which Stage to use. For inline scripts and local snippet references, pick a Stage from the row Actions menu — each option shows a checkmark on the current stage. Marketplace-installed snippet rows keep the publisher's default stage until you Clone the snippet. Save, edit, clone, delete, and stage changes live in each row's Actions menu.

Execution order for a list with two Main scripts looks like:

  1. All enabled Before all scripts (top to bottom)
  2. All enabled Before each scripts
  3. First Main script
  4. All enabled After each scripts
  5. All enabled Before each scripts again
  6. Second Main script
  7. All enabled After each scripts again
  8. All enabled After all scripts (top to bottom)

Before each and After each only run when at least one Main script exists. Before all and After all still run even when there are no Main scripts.

Variable values, hc.data mutations, and request mutations from earlier scripts in the same request stage are available to later scripts.

Execution order

When you send a request, scripts run in this order:

  1. Each enabled collection pre-request script, in list order
  2. Each enabled request pre-request script, in list order
  3. HTTP request is sent
  4. Each enabled collection post-request script, in list order
  5. Each enabled request post-request script, in list order

Disabled scripts, blank inline scripts, and missing snippet references are skipped. Within each request stage, variable values and hc.data from earlier scripts are available to later scripts and to {{variable}} substitution when the request is sent. Each executed script has its own timeout (default 5000 ms, configurable in Settings → General as Script timeout (ms); set to 0 to disable). Timeout applies per script in the run order, not per send. Console output is prefixed with the script label.