Skip to Content
FeaturesEnvironmentsOverview

Environments


Thunder Client Environment Variables

Common Variables: The following variables are available for all 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 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 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 for excluding 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 steps below:
    • Create an Environment (using option 1 in the image above).
    • 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 use this 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 want to link multiple collections to multiple environments. The values in this environment take precedence over the active environment. If you change environments frequently, this option is not recommended. 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 the request scope.
    • These variable values are available during the execution of the request only.
  • To use this, open collection settings or the request view, then select the 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 {{variableName}} format. You can use variables in Query Params, Headers, Body, and 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 the image above, option 4). More details here.

Set Environment Variable

  • Setting environment variables is supported in the Tests tab using the UI and scripting.
  • Please see the documentation here.
Last updated on