
This part had many people wrote tutorials, but there are some parts missing, so I rewrote it. Today I will share with you what is API environment
Table of Contents
Introduction about API environment
The main function of Environment is a place to save “variables” like “variables” in the code so that we can reuse it in many places.
Application:
– Quickly switch between Dev and Product environments without re-creating new requests because of having to change URLs again.
– Help save the value of the API response first to fill in the API later. (This part is combined with the Pre-request and Tests sections, which will be introduced in the next articles).
– Do not have to modify the value of the parameters too many times.
In Postman, it will be divided into 2 types of Environments: Local and Global
- Local: The scope of influence is only available when choosing the right Environments.
- Global: Scope affects all projects included in Postman, but if there are 2 variables with the same name in Local and Global, it will be preferred to get Local.
The location of Environment in the postman framework.

Create API enviroment
Step 1: Open Manage Environments

Step 2: Add a new Environment

Step 3: Enter the name of the Enviroment, the name and value of the variable. Here, I take an example with a url variable whose value is 192.168.1.77

The checkbox shows that: whether the variable is active or not. In the above example: I am active url variable and can use this variable in Demo-dev environment.
Get the value of the variables in request
Just write in the syntax {{variable_name}}: for example: {{url}}

As in the picture:
- position 1: Where to switch between Environments
- position 2: How to get variable value. Getting it right will be orange, hovering the mouse will display the value of the variable.
- position 3: If the variable name is red it means that the variable is not present in the Environment, this usually happens when switching between environments of different projects, or having the variable inactive.
How to view the values of variables in an API environment
Method 1: re-enter Manage Environment like Add Environment
Method 2. Click on the eye icon

If you want to edit the information of the Environment, you can click the Edit button to edit it.
What can be done with API enviroment?
Postman provides simple functions for an Environment such as: import – export, duplicate, add, edit, delete.

So, that’s it. Thank you for reading.
To read more articles about API testing , please go this link