Open In App

Edit and set environment variables in Postman

In Postman, the “environment” refers to a set of key-value pairs or a collection of variables used to customize requests. Environments allow you to define variables that can be reused across multiple requests, making it easier to manage different configurations for testing APIs or web services.

Features of Environment Variables:

Implementation of Environment Variables :

1. Setting environment variable :

Step 1: Create a request in a collection. In below image localhost may vary depending on development, testing, staging, and production. So, we can use the environment variable here.



Step 2 : In left-hand side of the Postman interface, you’ll see a menu labeled “Environments“. Click on “Create Environment“.



Step 3 : A tab will gets opened and we can add new variables, their types and values. Save the environment after adding all the variables.

Step 4: Use the variables in request and choose environment from top right corner “No Environment“.

Step 5 : Run the request and we will get the results as per our variable.

2. Editing an environment variable.

Step 1: Open the environment and update the variables (Here we can see that we have not added port 3000 in baseUrl variable, so let us edit this variable).

Step 2: Save it and then run the request again against the choosen environment (GFG Env).

Output :

Article Tags :