A Postman environment is a set of variables you can use in your Postman requests. This is really handy for grouping related sets of values for personal use, or for use as part of a team.
I use postman environments mainly because I have a production API plus some development APIs, and I use the same requests for both and use an environment variable to toggle between the hosts.
This is my basic set up for an environment that I use for all of my APIs.
Create a new environment
Select ‘Manage environments’ in the top right
Then select ‘Add’ on the ‘Manage Environments’ page:
Now just fill in the variable and the initial value in the table and select ‘Add’ in the bottom right:
You can add extra variables here for other parts of the url, but we can keep it simple for now.
Reference the variable
We now want to reference the HOST variable we just added in the request url. You can reference variables like this {{HOST}}.
Our newly created environment should now show up in the dropdown menu, and if you hover over the HOST variable you should see your staging server location.
You may have many different environments — just follow the same procedure and you will be able to switch between them more easily now!
I am planning to provide this tutorial as a basis for starting out with Postman environments, and maybe adding more Postman tips in the future. If you would like to see this please provide feedback in the comments, or claps.
Thanks!