top of page

Postman Playground : Mastering Variables and Beyond

Postman is a powerful API testing and development tool that streamlines the process of API testing and documentation. To enhance reusability , efficiency and flexibility .

They are three types of variables

Global Level Variables

Collection Variables

Environmental Variables

1) Global Level Variables: These variables that can be accessed and modifies across all collections and requests within the postman application. They are designed to store values that remain consistent throughout the entire test suite. These variables are particularly useful for storing credentials, access tokens or other data that multiple requests need to access.

Click on Environment to view the global variables created for the entire test suite.

Global Level variable

In the above screenshot we can see the variable stored at Global level.

There is the other icon “Environment quick look “ to have a quick look of the variables to check .

Quick view icon

· Set Global Level Variables: To set a value in the variable we use the code pm.globals.set (“ variable name “, value); Or we can manually create the variable key and assign the value to the global environment.

· Accessing Global Level Variables: To access a global variable, simply use the variable’s key wrapped in double curly braces (e.g., {{variable_key}}) anywhere in your requests or scripts.

2) Collection Variables :

Collection variables, as the name suggests, are specific to a particular collection. Unlike Global Level Variables, these variables are accessible only within the context of the collection in which they are defined. They are valuable when you want to store values that are consistent across requests within a single collection but may differ in other collections.

· Setting Collection Variables: To set a collection variable, follow these steps:

Open your desired collection in Postman. Click on the ellipsis (…) next to the collection name and select “Edit. “In the “Variables” tab, add a new variable with a key and value.

To create and set the value at the collection level we use pm.collectionVariable.set(“Variable name”,value);

Here pm.iterationData(“variablename “) is for extracting the value from the excel /data file which used for Data driven testing.

pm.collectionVariable .set(“batchName”,pm.iterationData.get(“BatchName ));

explanation of the above line of code : get is getting and set is setting .Lets read it from left to right. Getting the BatchName from datafile (iterationData) and setting the value under batchName at the collection Variable. Therefore it creates a variable name as batchName and set the value .

Data File:

Collection variable

· Accessing Collection level variable:

To access a collection variable, use the variable’s key in the same manner as Global Level Variables (e.g., {{variable Key}}) within the requests or scripts belonging to that specific collection.

3) Environment Variables: Environment Variables are specific to an environment in Postman . You can create multiple environments, each containing different values for the same variables. This is useful when you need to test against various environments (eg , UAT , development and production). You can switch between environments effortlessly, enabling you to adapt your API tests to different scenarios without modifying the requests or scripts.

To create environment variables:

· Click on the “ Manage Environments “ button on the top right corner of the postman window.

· In the “Manage Environments “ model , click on the “ Add “ button to create a new environment.

· Add key-value pairs for the variables you want to use within this environments.

To Use these variables in your requests, you can simply enclose the variable name within curly braces”{{variable_key}} within your request or scripts. However, these variables are tied to the currently active environment, so make sure we have selected the appropriate environment before execution.

One environments, global variables and collection level variables are not accessible in other environments but we can duplicate it by choosing duplicate option.


Postman’s Global level Variables, collection variables and environmental variables are essential tools for managing data and maintaining flexibility in API testing and development. The game is all about the variables which can be used for reuse to improve our workflow.

62 views0 comments

Recent Posts

See All

Beginner Friendly Java String Interview Questions

Hello Everyone! Welcome to the second section of the Java Strings blog. Here are some interesting coding questions that has been solved with different methods and approaches. “Better late than never!”


Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page