How to work with environment variables

How do you setup environments and define variables?

In this section, we’ll look at environment variables and how you can use them in API requests. Here are the two options in the toolbar which deals with configuring environments and switching between environments.

Environments Menu

When you click on the button to configure environment, it’ll open up a dialog box with all the configured environments.

Please note that pressing ESC will close the environments dialog.

Creating a new environment :

Click on the button to configure environments. If there are no environments configured then it’ll create a new ‘Default’ environment with a single environment variable. You can also click on the + button to add a new environment. The environment name is auto-generated but you can double click on the name to change it.

Adding New Environment

#### Copying an existing environment:

Click on the ++ button to copy an existing environment along with all the environment variables.

Copy Existing Environment

#### Deleting an environment:

Click on the - button to delete an existing environment.

Switching between environments:

A new environment can be selected from the main screen.

Switch Environment

Using environment variables:

An environment variable can be used in setting up the endpoint, any header or query param value or even in the request body. You can also define a dynamic enviornment variable whose value changes between each request. This is useful to define a random variable.

Press Ctrl/Cmd + G or press $ whereever you’d like to insert the value of the environment variable. This key combination opens up a text box which will auto filter environment variables as soon as you start typing. Once the environment variable is selected, press Enter to insert the variable.

Using Environment Variables