Postman – configure environment variables

PostMan is a relatively convenient interface testing tool, but during use, API requests may be created, but the API URL will change as the server IP address changes.

In this case, it would be very troublesome to re-modify the URL for every API, so PostMan also provides environment variable settings.

We can set the current environment Environment in the upper right corner of PostMan.

Tip: In actual daily work, we generally create a Collections folder for a module, a business process or a project, and put all the interfaces to be tested in this range into this Collections folder. At the same time, we will also add Folder, configure different environment variables for different environments, such as: local environment, test environment, production environment, etc.

1. Operation environment variable area in PostMan

In the upper right corner of PostMan, as shown below:

(1) The first one is: select the environment variables you defined before.

When we newly registered and started using PostMan, we did not define any environment variables, so nothing was displayed when we clicked the drop-down button.

(2) The second one is: quickly view the environment variables and global variables currently in effect in PostMan.

(3) The third one is: setting environment variables and global variables.

The previous version was a small gear icon

The meaning of the above picture in Chinese and English is:

  • Environment variables are a set of variables that allow you to switch the context of a request (that is, switching different requests can use the configuration in the environment variable), and you can also share the contents of the environment variable between multiple workspaces.
  • You can declare a variable in the environment and provide it with an initial value, then use it in the request by placing the variable name inside the {{ }}.
Now I have also found a lot of test friends and created a communication group to share technology, sharing a lot of technical documents and video tutorials we collected.
If you don’t want to experience the feeling of not being able to find resources when studying on your own, having no one to answer your questions, and persisting for a few days before giving up.
You can join us to communicate. And there are many technical experts who have made certain achievements in automation, performance, security, test development, etc.
Share their experience, and also share many live lectures and technical salons
You can learn for free! Focus on it! Open source! ! !
QQ group number: 110685036

2. Set environment variables

Take our previous example of “Query 02 College Information” as an example, as shown below:

(1) Configuration of environment variables

Click the Set Environment Variables button and click Add on the pop-up page.

Configure environment variables as shown below:


  • Environment Name: It is to give the environment variable a name, generally corresponding to Collections.
  • VARIABLE: variable name.
  • INITIAL VALUE: The initial value of the variable.
  • CURRENT VALUE: The current value of the variable.
    The current value of the variable is this value used when sending the request.
    The current value is never synced to Postman’s server. If no changes are made, the current value will automatically adopt the initial value.
    It is also explained in the prompt at the bottom of the interface above that if you need a variable to use reused values in different locations, you can set the current value of the variable to prevent sharing sensitive values with the team.
  • Persist All: Replace the previous initial values with the current values of all variables.
  • Reset All: Replace the initial values of all variables with the current values.
  • ...: Three dots, which are to check the display columns of the current page. The default is fine.

Finally, if you are adding an environment variable, click Add, if you are re-editing the environment variable, click Update. Afterwards, you will see the environment variables you just set in the environment variable setting page, as shown below:


  • Click the environment variable name to edit the content of the environment variable.
  • You can also perform the following operations on environment variables:
    • Share: Share current environment variables.
    • Duplicate Environment: Duplicate the current environment variables.
    • Download Environment: Download the current environment variables.
    • Manage Roles: Management roles. You need to log in to the team to perform this action.
    • Remove from workspace: Remove the current environment variables from the current workspace.
      If there is only one copy of the current environment variable, it only exists in this workspace and cannot be deleted. You can delete it permanently (using Delete) or share it to another workspace and delete it later.
    • Delete: Delete the current environment variable.

Summary: We can define the public variables or variables with special needs in all interfaces currently tested in environment variables.


Postman is very friendly to cooperative development. In Postman, you can invite friends to join the team to collaborate on testing and writing.
Click Invite to invite members to join the team. You can also create your own independent Workspace to isolate different projects. Workspace can be found in the top toolbar of Postman. Click the drop-down box to see the workspace you are in. Personal is your own workspace, and Team is the team you created. Or the workspace of a team you’re a part of.

As shown below:

(2) Use of environment variables

The use of environment variables is also very convenient. In the interface information or parameters, use {{variable name}} to call the environment variables.

For example, the same exercise as above.

Select the “College System Test” environment variable that you just configured. (When there are multiple sets of environment variables, you can choose to switch here)

Then use the content in the environment variable, as shown below:

Summary: In the future, we can define different environment variables for different test processes or different test environments.

  • Convenient modification of public variables.
  • Convenient to switch between different environments.

The above is the entire process of using environment variables in PostMan.

3. Set global variables

Global variables can be used for all requests in Postman without switching. The configuration and use of global variables are basically the same as the configuration and use of environment variables.

(1) Configuration of global variables

Click the Set Environment Variables button and click Globals on the pop-up page.

Configure global variables and click Save to save.

After saving, nothing will be displayed on the environment variables page, as shown below.

We can view global variables in Quick View.

(2) Use of global variables

The same as the use of environment variables, use {{variable name}} to call global variables.


There are some default global variables in Postman. When we enter {{ in the input box of the variable value, it will be displayed, as shown below :,

There are random ids, timestamps, random numbers, etc., which we can choose to use at our own discretion.

Special Note:

When a global variable and an environment variable have the same name, the environment variable has a higher priority than the global variable.

4. Quick view button

We can click the Quick View button to view global variables and currently active environment variables.

At the same time, you can directly modify the current values of environment variables and global variables in the quick view interface (the initial value cannot be modified, as mentioned before about the difference between the initial value and the current value), which is also a very practical function.

At the same time, you can also click Edit to directly re-edit environment variables or global variables.

5. Import environment variables

Click the Set Environment Variables button and click Import on the pop-up page.

We can import the Postman environment variables exported by others. The file is a .json file.

It’s very simple, so I won’t demonstrate it here.

6. Supplement:

When we call environment variables, we can see that E represents environment variables and G represents global variables.

Also, when the environment variable and the global variable have the same name, the environment variable will overwrite the global variable, as shown below:

In the display description of the global variable name, a horizontal line appears on the content, indicating that it will be overwritten by the name variable in the environment variable.

Finally: You can get a 216-page software test engineer interview guide document for free on my VX official account: [Automated Test Veteran]. And the corresponding video learning tutorials are shared for free! , which includes basic knowledge, Linux essentials, Shell, Internet program principles, Mysql database, packet capture tool topics, interface testing tools, advanced testing – Python programming, Web automated testing, APP automated testing, interface automated testing, testing Advanced continuous integration, test architecture development, test framework, performance testing, security testing, etc.

If my article is helpful to you, you can like it and support it