Open In App

How to create an environment in Postman?

Last Updated : 11 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Postman is a popular API testing tool that is used to simplify the process of developing and testing APIs (Application Programming Interface). API acts as a bridge between two software applications which enables them to communicate and share data. Postman provides a simple Graphical User Interface for sending HTTP requests Like GET, POST, Put, Delete, and view their responses.

What are environmental variables in Postman?

The environment is a set of variables in the form of key-value pairs (key: value) that we can use in our Postman requests. Environments are meant to be reused in different API requests, these variables store environment-specific information like base-URL for the API requests, and API-Keys and are automatically included wherever these variables are referenced. For example, the base URL of the API requests can be different can for different for the development and production, so we can create a separate environment for the development and a separate environment for the production.

How to Create Environment in Postman

Follow these steps to create Environments in Postman.

Step 1: Open Postman

Open Postman, if you haven’t downloaded, download and install Postman and Launch the application to get started.

For download instructions please refer to How to Download and Install Postman.

postman1-min

What are Environments in Postman? How to create them (fig.1)

Step 2: Access the Environment Tab.

In the top-right corner of the Postman interface, you’ll find a label No Environments (if you haven’t selected any environment). On the right side of the No Environment label, you’ll see an Environment Quick Look button click on it.

postman-2-min

What are Environments in Postman? How to create them (fig. 2)

Step 3: Create/Add a New Environment.

Click on the add button in the Environment Section to create a new Environment.

postman-3-min

What are Environments in Postman? How to create them (fig. 3)

Step 4: Name Your Environment

Give your environment a meaningful name for example you can name it “development” if you’re setting up variables for a development environment.

postman-4

What are Environments in Postman? How to create them (fig. 4)

Step 5: Define Environment Variables

Now that our environment is created, we can start initializing the environment variables-

  • Name: Name of the variable.
  • Type: Type of the variable content, the default type is shown as plain text whereas the Secret type masks the initial and current value for all the workspace members and is used for storing sensitive data like API-Keys.
  • Initial Value: Initial value of the variable, initial values are shared when you share an environment.
  • Current Value: Current Value of the variable, current values are not shared with the collaborators and are stored locally.
post-man5

What are Environments in Postman? How to create them (fig. 5)

Step 6: Using Environment Variables

You can use double curly braces to reference variables in your request URL’s like {{variable_name}}.

For example-

https://www.apiexample.com/post?secretkey={{secret_key}}

Step 7: Select the Active Environment

Now that we have created the Environment, make sure to select the active environment from the drop-down menu in the top-right corner before sending any requests.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads