# What is Postman Sandbox?

PostmanREST APISOAP API

Answer − Postman Sandbox is an Environment provided to execute JavaScript written as a part of the Pre-Request and Tests scripts for a request. This can be available for both Postman and Newman. Thus every script developed under the Tests or Pre-Request Scripts tab can be executed within this Sandbox.

Libraries and Utilities used in Postman Sandbox −

• Lodash - a utility in the JavaScript library.
• cheerio.
• BackboneJS.
• SugarJS.
• CryptoJS.

Environment, Global, Dynamic variables & Cookies

To set an Environment variable, we have to add the below script −

postman.setEnvironmentVariable(name of variable, value of variable)

To set a Global variable, we have to add the below script −

postman.setGlobalVariable(name of variable, value of variable)

To get an Environment variable, we have to add the below script −

postman.getEnvironmentVariable(name of variable)

To get a Global variable, we have to add the below script −

postman.getGlobalVariable(name of variable)

To clear an Environment variable, we have to add the below script −

postman.clearEnvironmentVariable(name of variable)

To clear a Global variable, we have to add the below script −

postman.clearGlobalVariable(name of variable)

To clear all Global variables, we have to add the below script −

postman.clearGlobalVariables()

To access/read a particular Environment variable say e1 we have to add the below script −

Environment["e1"]

To access/read a particular Global variable say G1 we have to add the below script −

globals["g1"]

To get all cookies for a domain, we have to add the below script −

To obtain response cookie with name say c, we have to add the below script −

{{$timestamp}} To add a random integer from 0 to 5, we have to add the below script − {{$randomInt}}