A variable is a reusable value you can use in API requests and scripts. Postman will use the variable's current value when running a request or script. You can group variables in an environment to make it easier to change variable values based on your work context.
To create and use a variable, do the following:
Select Environments in the sidebar, then select Globals.
Add a variable named my_variable
and give it an initial value of Hello
.
Select Save, then close the Globals tab.
Open a new request tab and enter https://postman-echo.com/get?var={{my_variable}}
as the URL. Hover over the variable name to inspect the variable's value and scope.
Select Send and send the request. Inspect the response, which confirms that Postman sent the variable value to the API.
Select Variables in the workbench to open the variables pane.
Under Variables used, change the value of my_variable
and send the request again.
To learn more about using variables in Postman, go to Store and reuse values using variables.
With environments, you can create sets of variables for the various types of work you do in Postman. For example, you might want to use different values when sending requests to a test server or a production server.
To get started, learn how to create and switch between environments In Postman. You can then add and edit variables in each environment. You can also use environments to collaborate with your team and share and manage sensitive data.
Last modified: 2024/02/07
Additional resources
Videos
Blog posts
Case Studies