An environment is a group of variables whose values you can change depending on your work context in Postman. After you create an environment, you can add new environment variables, change initial or current values, or delete variables. You can also set environment values using scripts, and you can persist variable values to make them available to your team.
You can edit environment variables by adding new variables, changing a variable's type and values, or deleting variables.
If you're working with environments as part of a team, you must have the Editor role to edit the environment or change initial values for variables. Learn more about managing environment roles.
To edit environment variables, select Environments in the sidebar and select an environment. From here you can take the following actions:
To edit an environment variable, select the variable and change any of the following:
Variable - The name of the variable. Use the name to reference the variable in requests and scripts.
Type - If you select default, the variable value is visible in plain text. If you select secret, the variable value is masked. Learn more about variable types.
To show or hide a secret variable, hover over the variable and select the eye icon .
Initial value (shared) - This value is synced to your account using Postman's cloud servers. It's shared with any collaborators who have access to the environment. It's also made public when publishing an environment along with a collection.
It's recommended that you use your Postman Vault to store sensitive data, such as API keys, as vault secrets. Only you can access and use values associated with your vault secrets, and vault secrets aren't synced to the Postman cloud. If you want to share sensitive data with collaborators, you can store it in an environment as a secret type variable.
Current value (local) - This value is used when sending requests in your local instance of Postman. It's never synced to your account or shared with your team unless you choose to persist it. If you leave the current value blank, the initial value is copied to the current value when you save the environment.
When you're done editing environment variables, select Save to save your changes.
Use the variables pane to view and edit the current value for variables in the active environment. You can view the environment variables used in the request that's open. You can also view the environment variables in the active environment from a Postman element.
Choose an environment from the environment selector, then select Variables to open the variables pane. Delete the existing current value of an environment variable, then enter a new current value.
You can also hover over the reference to the environment variable, delete the existing current value, then enter a new current value.
Learn more about viewing and editing variables from an element.
You can change the values of environment variables from your Pre-request and Post-response scripts. Use the pm.environment
method to set an environment variable in the active environment:
pm.environment.set("variable_key", "variable_value");
If you use scripts to set values for environment variables, these values will be reflected in all requests that reference the variables. For example, you can use environments in conjunction with the collection runner and monitors to use updated values for a series of requests throughout a run and after the run completes.
To create new environment variables from a script, you must have Editor access to the environment. If you update or unset a value in a script when you have Viewer access, that change will be visible to you but won't be shared with other team members. Learn more about managing environment roles.
An environment variable's current value is used in your local instance of Postman and isn't synced to your Postman account or shared with your team. If you want to sync an environment variable's current value with your account or share it with team members, you can persist the variable.
When you persist a variable, the variable's initial (shared) value is set to the current (local) value. The initial value is then synced to your Postman account, and anyone who has access to the environment can view the new initial value. If a variable's initial value has sensitive data, it's recommended that you use vault secrets to prevent exposing the value when sharing or publishing the environment. If you want to share sensitive data with collaborators, you can store it in an environment as a secret type variable.
To persist a variable, you must have Editor access to the environment. Learn more about managing environment roles.
To persist an environment variable, do the following:
At any time you can reset a variable's current (local) value with the initial (shared) value synced to your workspace. Select the more actions icon next to a variable and select Reset. The current value is replaced by the initial value. Select Save to save the change.
You can persist or reset all variable values in the environment at once. Select the more actions icon in the column header, then select Persist All or Reset All.
Last modified: 2023/11/09