Environment Variable Interpolation in Hoppscotch API Requests
How Hoppscotch resolves ${{VAR}} placeholders across global workspace and collection scopes with trust boundaries operational verification and failure modes for safe API design.
26 Feb 2026, 00:36 UTC

Requirements: dynamic values without client-side scripting
API testing workflows frequently need to adapt requests based on the target environment-swapping base URLs inserting auth tokens or toggling feature flags. Doing this manually per request creates maintenance burden and error risk. Hoppscotch provides a per-workspace environment variable store that lets you define values once and reference them across any request in the workspace collection or globally using the ${{VAR}} syntax.
Smallest suitable design
Hoppscotch stores variables in a JSON file scoped to each workspace (the hoppscotch_storage key in browser local session storage). The interpolation engine uses a two-pass rendering model:
- Collection phase: gather all variables from global workspace and collection scopes respecting the defined priority (global to workspace to collection). A variable defined at collection level overrides the workspace or global definition for that collection only.
- Substitution phase: after the request payload URL headers body is serialized every occurrence of ${{VAR}} is replaced with the variables resolved value. This order prevents circular references from causing runtime errors and supports nested definitions such as ${{BASE_URL}}https://api.example.com and ${{API_PATH}}/v1/users.
Because substitution happens after serialization the final HTTP request sent from the browser contains fully resolved strings-no placeholder syntax reaches the network.
Trust and data boundaries
Since variable resolution occurs entirely on the client the resolved values may appear in browser storage DevTools output or HTTP proxy captures e.g. Burp Suite. This has direct implications for secrets handling:
- Auth tokens API keys or secrets should never be placed in URL query strings or header values that are logged externally.
- Hoppscotch masks values marked as secret in the UI replacing them with asterisks in the variable store but the masked value is still resolved at runtime if used in a request.
- Collection-level scope overrides ensure that a variable in one collection cannot silently alter requests in another collection but developers must still validate that sensitive values are not inadvertently exposed through error messages or debug logs.
Operational checks
To verify that interpolation works as expected and that data boundaries are respected perform the following checks:
- Open the DevTools Application panel. Locate the Hoppscotch storage key typically named hoppscotch_storage. Inspect the keys value; variable definitions appear as plain JSON key-value pairs.
- Create a collection with two variables: set VAR_BASE=https://api.example.com and VAR_PATH=/v1/status. Add a GET request with the URL set to https://${{VAR_BASE}}/${{VAR_PATH}}. Send the request and confirm the UI preview shows https://api.example.com/v1/status not the placeholders.
- Launch a proxy e.g. Burp Suite and capture the outbound request. Compare the rendered URL in the proxy with the Hoppscotch UI preview. They should match exactly any remaining ${{VAR}} indicates a scope resolution issue or an unresolved circular reference.
- Test scope priority by defining the same variable name at global workspace and collection levels. Send a request from the collection and verify that the collection-level value is used while other collections still resolve to the workspace or global value.
Failure modes and conditions that would change the design
- Unresolved placeholders: If a variable references a scope that does not contain a definition the placeholder ${{VAR}} remains in the serialized request. The server receives the literal string and may return a 400-level error. This is detectable via the proxy check described above.
- Circular references: Defining VAR_A=${{VAR_B}} and VAR_B=${{VAR_A}} triggers the two-pass model to abort substitution for both variables leaving placeholders intact. This intentional guard prevents infinite loops during rendering.
- Secret leakage via URLs: Variables expanded into request URLs may be captured in server access logs or browser history. For credentials use dedicated secret-management integrations or avoid interpolation into URL paths.
- Scope bleed-over: Although the priority order (global to workspace to collection) prevents unintended overrides mis-configured collection variables can affect shared workspaces. Regularly audit collection variables when collaborating across teams.
When an organizations security or compliance requirements outgrow client-side variable resolution-for instance when secrets must be managed in a vault external to the browser-replacing Hoppscotchs interpolation with a server-side API gateway or dedicated secrets manager becomes the appropriate design shift.