Demystifying Postman Variables: HOW and WHEN to use Different Variable Scopes
Are you confused about the different variable types in Postman, like global, collection, environment, local, data variables? Hopefully, this will make your life easier.
Variables are a very powerful feature of Postman. Not only it allows you to save and manage some repeating information (like URLs, authentication tokens or keys, and so on) but by using scripts, you can pass data from one request to the next thus creating some very advanced workflows. But they can also cause a lot of confusion and uncertainty.
✅ UPDATED in January 2021. All the information in this article is up-to-date.
I have documented how to use the Postman variables within scripts in the Postman Quick Reference Guide which you can view online or download a PDF.
Similar to many programming languages, Postman uses scopes when defining variables. Currently, the following scopes are available:
- Global
- Collection
- Environment
- Local
- Data
Let's next try to understand what is the deal with these scopes, why they are needed, and when to use them.