Knowband Blog | Ecommerce Modules

How to Use Environments in Postman?

What are Environments?

When working with APIs, you will often need to have different configurations. For example, your local machine, the development server, or the production API. Environments provide the ability to customize requests using variables. This way, you can easily switch between different settings without changing your requests. You won’t have to worry about remembering all these values once they’re in Postman. Environments can be downloaded and saved as JSON files and loaded later.

Steps to Create a New Environment

Click the Environments section in the left menu.

Click the Add button or Create Environment to create a new environment.

Click the Add button to create a new environment.

Provide the environment name such as local/development or production.

Each environment is a set of key-value pairs, with the key as the variable name.

for example, here we create two keys that can be used when triggering APIs

API_URL

APP_VERSION

We can also define global variables that can be accessible in all environments. Click on the global button. 

Set the key values as previously defined when creating an environment and click the save button.

Steps to Use Environment

Select an active environment

Click the drop-down menu in the top right corner of the Postman app to select an active environment, or type the environment name. After selecting an environment, you can access variables in the scope of the active environment.

Access Environment Variables

Once you’ve chosen the platform, you can easily access the variable in the Body, Headers, or Request URL.

Note: The variable name will be enclosed in double braces. for example, {{API_URL}}. You can also get the variable suggestion by typing simple braces ‘{‘

In the screenshot below, we have used variables in Request Url and Body parameters.

Note: Global and environment variables will always be stored as strings. If you are storing objects/arrays, be sure to JSON.stringify() before storing them and JSON.parse() during retrieval.

For any queries, please feel free to reach us at support@knowband.com.

You can also take a look at the best eCommerce modules provided by Knowband for Prestashop, Opencart, Magento, and Magento 2.

Check out our top selling Modules:

Prestashop Android and iOS Mobile App Builder Addon

Android and iOS App Maker for Opencart

One Page checkout addon for Prestashop

Knowband Mobile App Builder

Get the mobile app created for your store in a few hours with the Knowband Mobile App Builder Module.

Learn More