Edit and set environment variables in Postman

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, update their values, or delete variables. You can also set environment values using scripts, and you can share variable values to make them available to your team.

Edit environment variables

You can edit environment variables by adding new variables, changing a variable's value, marking a value as sensitive data, or deleting variables.

If you're working with environments as part of a team, you must have the Editor role to edit the environment and its values. Learn more about sharing environments.

To edit environment variables, select Environments in the sidebar and select an environment. From here you can take the following actions:

  • To filter the list of environment variables by name or value, click Search icon Search Variables, and enter your search.
  • To sort the list of environment variables, select a column header. You can toggle between ascending and descending order. To manually sort the list, clear the sort order if needed by selecting a column header, then drag rows using the handles.
  • To add a new environment variable, select Add new variable in the bottom row of the table.
  • To delete an environment variable, hover over a variable and select the delete icon Delete icon.
  • To make an environment variable unavailable without deleting it, clear the checkbox next to the variable. Any references to the variable will be empty variables without a value. To make the variable available again, select the checkbox.

Environment editor

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.
  • Sensitive data - Click Key icon Mark as sensitive next to the variable name to set the variable as sensitive data, masking the value in Postman. Learn more about setting a variable as sensitive data.
  • Value - This value is used when sending requests in your local instance of Postman. It's never synced to the Postman cloud or shared with your team. You can optionally share the environment variable's value, syncing it with the Postman cloud.

Changes to your variables are automatically saved.

Edit variables from the variables pane

Use the variables pane to view and edit the local 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 Variable list icon Variables to open the variables pane. Delete the existing value of an environment variable, then enter a new value.

You can also hover over the reference to the environment variable, delete the existing value, then enter a new value.

Learn more about viewing and editing variables from an element.

Set environment variables from scripts

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 sharing environments.

Last modified: 2025/04/18