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 use OS System environment variables as global variables using the format {{variable}}.
  2. Global Environment: You can use Global Environment to save variables and share them with all collections. The values will be stored in the main thunderEnvironment.json file. (See above image, 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. The values will not be saved in the main thunderEnvironement.json file (See above image, option 3)
  4. env file: 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:
  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");

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

  • 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.