Group sets of variables in Postman using environments

In Postman, an environment is a set of one or more variables that you can reference when sending requests, writing pre-request scripts, or writing post-response scripts. You can create environments for the different types of work you do in Postman. When you switch between environments, all of the variables in your requests and scripts will use the values from the current environment. This is helpful if you need to use different values in your requests depending on the context, for example, if you're sending a request to a test server or a production server.

Environments can also help you to collaborate on Postman data if you're working as part of a team. You can use environments to share variables and manage the visibility of sensitive data such as API keys, passwords, or tokens. Learn more about working with environments as a team in Postman.

Create an environment

Create a new environment when you want to be able to change the values of variables depending on your work context in Postman, or to share values with other team members. You can also create a new environment from the environment selector, making it the active environment.

To create a new environment, do the following:

  1. Select Environments in the sidebar and select Add icon. You can also select the environment selector at the top right of the workbench and select Add icon.

    Create new environment
  2. Enter a name for your new environment.

  3. Add any variables you want to the environment. You can also add variables later. Learn more about adding environment variables.

    Changes to your variables are automatically saved.

  4. To use the new environment, select it from the environment selector at the top right of the workbench. This makes it the active environment and sets all variables to the values specified in the environment. Learn more about switching between environments.

    Environment selector

    If you created it from the environment selector, the new environment will already be the active environment.

You can turn on autosave to automatically save your changes to collections, requests, and environments. Learn more about autosave.

Add environment variables

You can specify a local value when you add an environment variable. This means the value isn't synced to the Postman cloud or shared with your teammates.

To add variables to an environment, do the following:

  1. Click Environments in the sidebar and select an environment.
  2. Click the Add variable text box and enter a variable name.
  3. Enter a value.
  4. (Optional) Click Description icon Add description next to the variable name then enter a description of the variable.
  5. (Optional) 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.

Learn about more options for defining environment variables in your workspace.

You can optionally share an environment variable value if you have Editor access, syncing the value to the Postman cloud. This enables you to share the value with your teammates. This also enables you to use the variable with Postman features that run on the Postman cloud.

Changes to your variables are automatically saved.

Switch between environments

Postman displays the active environment in the environment selector, located in the top right of the workbench. When you send a request or run a script, Postman uses the local value for all variables in the active environment. To make another environment active, select it from the environment selector.

Environment selector

You can select Add icon in the environment selector to create a new environment and make it the active environment.

You can also make an environment active by selecting Environments in the sidebar. Select the set active icon Set active icon next to an environment to make it the active environment.

Active environment

To check a variable's local value, select Variable list icon Variables in the workbench to open the variables pane. The variables pane lists the local values for all variables in the active environment.

If you want to make variables available regardless of which environment is active, use global variables. The quick look lists any global variables you have declared or that are shared in your workspace.

Use variables in requests and scripts

To use an environment variable in a request, reference it by name surrounded with double curly braces:

{{base_url}}

You can reference environment variables in request URLs, parameters, headers, and body data. Hover over a variable reference to view its local value.

Reference variable

You can access current environment variable values in your Pre-request and Post-response scripts using the pm.environment.get method:

pm.environment.get("variable_name");

If more than one variable with the same name is available to a request, Postman will use the value from the variable with the narrowest scope. Therefore, if you have an environment variable with the same name as a collection or global variable, Postman will use the environment variable. However, local and data variable values will supersede environment values. The value of any overridden variables will display in strikethrough format.

Learn more about editing and setting environment variables in Postman.

Edit an environment

If you're working with environments as part of a team, you must have the Editor role to edit the environment or change shared values for variables. Learn more about sharing environments.

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

  • To rename an environment, select the environment's name and enter a new name.

  • To duplicate an environment, select the more actions icon More actions icon and select Duplicate.

  • To delete an environment, select the more actions icon More actions icon and select Delete. Deleting an environment also deletes all variables in the environment.

Next steps

Environments enable you to share data in Postman and collaborate with your team. Here are some more resources to help you use environments with your team:

Last modified: 2025/04/18