Environments in Run in Postman

There are 2 ways to include an environment with the shared collection using the Run in Postman button.

While generating the embed code

select environment

Select the environment name from the dropdown, as shown in the screenshot above. The environment is now embedded within the generated HTML/Markdown and will be imported when your user clicks the button.

On page load using Run in Postman’s JavaScript API

Postman also provides an API to programmatically generate an environment client-side.

_pm('env.create', 'Spotify', {
  user_id: 'spotifyuser',
  authorization: 'Bearer 1234xyzd'
});

A possible application for this would be to pass your signed in user’s access credentials to Postman, as illustrated in the example above.

Note that this method works only with the CSS button, and not the Markdown button. The _pm() method can be used anywhere on the page, after the embedded script tag.