Features
Environments
Overview

Environments


Thunder Client Environment Variables

Common Variables: The following variables are available for all the requests {{request_name}}, {{collection_name}} and {{folder_name}}

The following environments can be used in Thunder Client, ranked from least to highest precedence:

  1. OS Environment Variables:
    You can reference OS system environment variables as global variables using the format {{variable}}.
  2. *Global Environment:
    Global Environment allows you to store variables that can be accessed across all collections. These values are saved in the file tc_env_global.json file. (Refer to the image above, option 2).
  3. *Local Environment:
    You can use Local Environment to save secrets and transient tokens locally on your computer; useful to exclude secrets from a git project. This environment is a global type and the variables are available to all collections. (Refer to the image above, option 3)
  4. *env files:
    You can use .env files in Thunder Client. To use a .env file follow the below steps:
    • Create an Environment (using option 1 in above image).
    • Open the Environment view, where you will see the option Link to .env file.
    • Select the .env file and save it. Now you can use the variables in Requests using {{variable}}.
    • The variables in the .env file should be in the format:
    .env.sample
    key=value
    name=thunder
    number=25543
  5. Active Environment:
    To use an environment's variables, you need to make it active using the options menu ..., then select Set Active.
  6. Attach Env to Collection (Optional):
    You can attach an environment to a collection from the Collection Settings view. Use this option when you'd like to link multiple collections to multiple environments. The values in this environment will take precedence over the active environment. If you change environments frequently, this option is not recommended. Please see the example below:
    CollectionA -> EnvA
    CollectionB -> EnvB
    CollectionC -> EnvC
  7. *Collection and Request Variables
  • You can set collection and request specific env variables in scripting using request scope.
  • These variable values are available during the execution of the request only.
  • To use - open collection settings or request view -> then select Pre Run Tab and use the Scripting tab
tc.setVar("name", "Thunder Client", "request");
tc.setVar("baseUrl", "http://localhost:8744", "request");
* These features are available only in the paid version.

How to use Environment Variables

  • To use environment variables use the format {{variableName}}. You can use variables in Query Params, Headers, Body & Tests.

Import .env files

This feature is available only in the paid version..
  • You can import Thunder Client, Postman and .env files using the Import Menu Option (see above image, option 4). More details here.

Set Environment Variable

  • Setting Environment variables is supported in the Tests tab using UI and scripting.
  • Please see the documentation here.