- Introduction
- Installation and updates
- Sending your first request
- Creating the first collection
- Navigating Postman
- Keyboard Shortcuts
- Postman account
- Syncing
- Settings
- New button
- Collaboration
- Troubleshooting In-app Issues
- Customizing Postman
- Find and Replace
- Requests
- Responses
- History
- Troubleshooting API requests
- Debugging and logs
- Authorizing requests
- Cookies
- Certificates
- Capturing HTTP requests
- Interceptor extension
- Proxy
- Generate code snippets
- Making SOAP requests
- Working with Tabs
- Using GraphQL
- Visualize API responses
- Intro to collections
- Creating collections
- Sharing collections
- Managing collections
- Requesting access
- Using Markdown for descriptions
- Examples
- Data formats
- Working with OpenAPI
- Commenting on collections
- Version Control for Collections
- Intro to scripts
- Pre-request scripts
- Test scripts
- Test examples
- Branching and looping
- Postman Sandbox
- Postman Sandbox API reference
- Intro to collection runs
- Starting a collection run
- Using environments in collection runs
- Working with data files
- Running multiple iterations
- Building workflows
- Sharing a collection run
- Debugging a collection run
- Command line integration with Newman
- Integration with Jenkins
- Integration with Travis CI
- Newman with Docker
- Documenting your API
- Viewing documentation
- Authoring your documentation
- Publishing your docs
- Custom documentation domains
- Intro to Monitoring
- Setting up a monitor
- Viewing monitor results
- Monitoring APIs and websites
- Set up integrations to receive alerts
- Pricing for monitors
- Troubleshooting monitors
- FAQs for monitors
- Intro to mock servers
- Setting up a mock server
- Mocking with examples
- Mocking with the Postman API
- Matching algorithm
- Notifications
- Introduction to APIs
- Managing APIs
- Sharing APIs and managing roles
- The API Workflow
- Versioning APIs
- Reporting FAQs
- Viewing and analyzing APIs
- What is Postman Pro
- Intro to Enterprise
- Purchasing Postman Enterprise
- Running Postman monitors using static IPs
- Intro to SSO
- Configuring SSO for a team
- Logging in to an SSO team
- Configuring Microsoft AD FS with Postman SSO
- Setting a custom SAML in Azure AD
- Setting up custom SAML in Duo
- Setting up custom SAML in GSuite
- Setting up custom SAML in Okta
- Setting up custom SAML in Onelogin
- Setting up custom SAML in Ping Identity
- Audit logs
Run in Postman button API
The JavaScript Run in Postman button exposes an API via the _pm()
method. These API methods allow you to dynamically alter button behavior. Note that the _pm()
API is not available for the static version of the Run in Postman button.
Creating a new environment
A new environment can be dynamically created using the env.create
method:
_pm('env.create', 'environment_name', {key: value});
For example, if you need to create a new environment using API keys entered by your user, you can do something like this when the Run in Postman button is clicked:
function () {
var stagingKey = document.getElementById('staging-key-input').value,
productionKey = document.getElementById('production-key-input').value,
envData = {
stagingKey: stagingKey,
productionKey: productionKey
};
_pm('env.create', 'API Keys', envData);
}
Note:
- The
env.create
action will return truth on success, false on failure. env.create
cannot be used to create duplicate environments. Subsequent calls with an existing environment name will fail.
Editing an existing environment
An environment which was included in the Run Button embed code or created with env.create
can be modified using the env.assign
method:
_pm('env.assign', 'environment_name', {key: new_value, new_key: value})
For example, if you need to update the API Keys
environment created in the last example:
function () {
var stagingKey = document.getElementById('staging-key-input').value,
productionKey = document.getElementById('production-key-input').value,
envData = {
stagingKey: stagingKey,
productionKey: productionKey
};
_pm('env.assign', 'API Keys', envData);
}
Note:
- The
env.assign
action will return truth on success, false on failure. env.assign
cannot be used to create new environments. Calls to_pm
usingenv.assign
will fail if the environment doesn’t already exist.env.assign
will allow assignment to environments created usingenv.create
and inline environments from the button embed code.
Replacing an existing environment
An entire environment can be replaced using the env.replace
method.
_pm('env.replace', 'environment_name', {key: value})
For example, if you have the following environment and you need to replace it:
// Existing environment named 'user_data'
// {
// auth_token: 'q4yugoiwqu4hlrjksfdm3897ryq3891s',
// user_id: '823',
// session_data: {}
// }
// Replace the 'user_data' environment
_pm('env.replace', 'user_data', {});
Note:
- The
env.replace
method will return truth on success, false on failure. env.replace
cannot be used to replace an environment which does not exist.