For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Postman
PricingEnterprise
Contact SalesSign InSign Up for Free
HomeDocs
HomeDocs
      • Overview
        • Overview
          • Overview
          • Publish your public APIs
            • Overview
            • Create Run in Postman button
            • Customize Run in Postman button
        • Maintain your public APIs
        • Explore your publisher tools
        • Analyze developer engagement
Postman API Platform

Product

  • Postman Overview
  • Enterprise
  • Spec Hub
  • Flows
  • Agent Mode
  • API Catalog
  • Fern
  • Postman CLI
  • Integrations
  • Workspaces
  • Plans and pricing

API Network

  • App Security
  • Artificial Intelligence
  • Communication
  • Data Analytics
  • Database
  • Developer Productivity
  • DevOps
  • Ecommerce
  • eSignature
  • Financial Services
  • Payments
  • Travel

Resources

  • Postman Docs
  • Academy
  • Community
  • Templates
  • Intergalactic
  • Videos
  • MCP Servers

Legal and Security

  • Legal Terms Hub
  • Terms of Service
  • Postman Product Terms
  • Security
  • Website Terms of Use

Company

  • About
  • Careers and culture
  • Contact us
  • Partner program
  • Customer stories
  • Student programs
  • Press and media
Twitter iconLinkedIn iconGithub iconYouTube iconInstagram iconDiscord icon
Download Postman
Privacy Policy

© 2026 Postman, Inc.

On this page
  • Create a new environment
  • Pass a user’s sign-in credentials
  • Edit an existing environment
  • Replace an existing environment
  • Remove an existing environment
  • Use multiple buttons with separate environments
  • Get all environments
  • Next steps
Postman API NetworkPublish to the Postman API NetworkPublish your public APIsAdd Run in Postman button

Customize your Run in Postman button

||View as Markdown|
Was this page helpful?
Previous

Create a Run in Postman button for your API consumers

Next

Maintain your public APIs for the Postman API Network

Built with

As an API publisher, you can dynamically inject information as environment variables into the Run in Postman button. You can customize and embed this button in your website’s client-side code so users can begin making calls to your API using Postman’s _pm() method. The Run in Postman button enables users who click it to fork your collection and environment into their Postman workspace.

Create a new environment

Create a new, empty environment using the env.create method:

1_pm('env.create', 'environment_name', {key: value}, runButtonIndex);
Important

You can’t use this method to duplicate environments. Any calls made using existing environment names will fail.

Create a new environment using API keys entered by your user:

1function () {
2 var stagingKey = document.getElementById('staging-key-input').value,
3 productionKey = document.getElementById('production-key-input').value,
4 runButtonIndex = 0,
5 envData = {
6 stagingKey: stagingKey,
7 productionKey: productionKey
8 };
9
10 _pm('env.create', 'API Keys', envData, runButtonIndex);
11}

The env.create method returns the total number of environments associated with Run in Postman buttons on the page on success and false on failure.

Note

This creates an environment, but doesn’t set it as the active environment.

Pass a user’s sign-in credentials

Create an environment that contains the user’s sign-in credentials:

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

Edit an existing environment

Update an environment using the env.assign method:

1_pm('env.assign', 'environment_name', {key: new_value, new_key: value}, preventOverride, runButtonIndex);

This method works for environments included in the Run in Postman button on creation, or environments added using the env.create method.

Important

You can’t use this method to create new environments. Any calls made using the env.assign method fail if the environment doesn’t already exist.

Update an environment’s API keys:

1function () {
2 var stagingKey = document.getElementById('staging-key-input').value,
3 productionKey = document.getElementById('production-key-input').value,
4 preventOverride = true,
5 runButtonIndex = 0,
6 envData = {
7 stagingKey: stagingKey,
8 productionKey: productionKey
9 };
10
11 _pm('env.assign', 'API Keys', envData, preventOverride, runButtonIndex);
12}

The env.assign method returns true on success and false on failure.

Replace an existing environment

Replace the entire contents of an environment using the env.replace method:

1_pm('env.replace', 'environment_name', {key: value}, runButtonIndex);

The env.replace method returns true on success and false on failure.

Important

You can’t use this method to replace an environment which doesn’t exist.

Remove an existing environment

Remove an existing environment using the env.remove method:

1_pm('env.remove', 'environment_name', runButtonIndex);

The env.remove method returns true on success or false on failure.

Important

The environment must exist or this method will fail.

Use multiple buttons with separate environments

You can embed multiple buttons on a single page. To include a different environment for each Run in Postman button, enable the segregateEnvironments property:

1_pm('_property.set', 'segregateEnvironments', true);

If you enable segregateEnvironments, you must use runButtonIndex in all _pm() methods to reference each button according to its position in your page DOM:

1var runButtons = Array.prototype.slice.call(document.getElementsByClassName('postman-run-button')),
2 runButtonIndex = runButtons.indexOf(elem);
Note

Because segregateEnvironments is deactivated by default, runButtonIndex is optional by default.

Use the index for jQuery

Use the following to return a jQuery object containing an index of all elements matching the postman-run-button query:

1var runButtonIndex = $('postman-run-button').index(elem);

The response contains the index location for all elements that match.

Get all environments

Use the get() method to retrieve all environments:

1_pm('_property.get', 'environments');

This returns a response containing an array of the available environments:

1[
2 {
3 "button_index": 0,
4 "name": "env1",
5 "values": [
6 {
7 "key": "testKey",
8 "value": "testValue",
9 "enabled": true
10 }
11 ]
12 }
13]

Next steps

After creating a Run in Postman button, you can share your API with users by creating documentation in a public workspace.

  • To learn how to create API documentation in Postman, see Document your APIs in Postman.
  • To learn how to add your documentation to your public workspaces, see Publish documentation in Postman.