Skip to main content
Variable interpolation is the mechanism that replaces {{placeholder}} expressions with actual values at runtime. This page covers all interpolation contexts, resolution rules, and advanced patterns.

Interpolation Syntax

All interpolation uses double curly braces:

Where Interpolation Works

Variables can appear in:

Variable Sources

Inline Variables

Defined at the top of a .http file:

Environment Variables

From hitspec.yaml environments section:

System Environment Variables

Using the $env() function:

Built-in Functions

Dynamic values generated at runtime:

Captured Values

Values extracted from prior responses:

Resolution Order

When the same variable name exists in multiple sources, hitspec resolves in this order (later sources win):
  1. Config environments — hitspec.yaml environments section for the active --env
  2. Inline variables — @variable = value in the file
  3. Captured values — {{requestName.captureName}}
Built-in functions ($uuid(), $timestamp(), $env(), …) and system variables ({{$VAR}}) are evaluated wherever they appear. An inline variable that references its own name, such as @baseUrl = {{baseUrl}}, resolves that reference against the lower layers (the config environment, then .env, then the OS environment). The file default therefore delegates to the environment. Captured values are inserted literally. A captured value that contains {{...}} (for example a response body with {{$env(SECRET)}}) is never expanded, so a server cannot read your local variables through a capture.

Capture Chains

Chain captures across dependent requests:
Step 3 references captures from both Step 1 (login.token) and Step 2 (createResource.resourceId).

Nested Interpolation

Variables can reference other variables:
Captured and interpolated non-string values are inserted as their JSON text: numbers keep their exact digits (1000000, 123456789012), booleans are true or false, null is null, and objects and arrays are compact JSON.

Unresolved Variables

If a variable cannot be resolved, it remains as the literal {{variableName}} string in the request. hitspec does not error on unresolved variables — the request is sent with the raw placeholder, which typically causes a server-side error that surfaces through your assertions.
Use --verbose (or -v) to see resolved variable values in the output, which helps debug interpolation issues.
Last modified on October 19, 2026