You can curate your public collection’s developer experience for your API consumers by setting up authentication and authorization, variables and environments, and scripts and tests.
A collection with a great developer experience invites your API consumers to fork and use your APIs. It also gets them to their first 200 OK response in the fewest steps possible.
Protect your sensitive data. If Postman detects any API keys, tokens, or similar, it replaces them with placeholders. To learn more, see Postman Secret Scanner.
Postman recommends you set up Guided Auth with OAuth 2.0 for your domain. Once you set it up, and an API consumer uses an endpoint on your domain, Postman prompts them to authenticate through Guided Auth. This is the fastest way to authenticate and creates the best developer experience.
If necessary, Postman supports a variety of authorization types, which you can also set up.
To learn more, see API authentication and authorization in Postman.
To set up Guided Auth for your domain, do the following:
You can also choose one of the other authorization types.
To learn more, see Set up Guided Auth for public APIs in Postman.
If you’re not ready to set up Guided Auth, you can set up authorization for your collection. All requests in the collection inherit the authorization details you set up.
Open your collection’s Authorization tab and choose an Auth Type. Enter your API’s authorization details. When your API consumers fork your collection, they’ll complete the remainder of the details.
To learn more, see Add API authorization details to requests in Postman.
You can create variables in your workspace to improve the developer experience. For example, you can create a variable for an API consumer’s API key and use the variable throughout your requests. An API consumer can later update the variable’s value with their API key in one place.
You can set up variables for different scopes, such as your collection or an environment.
API consumers can’t fork your global variables. Don’t use them in your public workspace. Use collection and environment variables instead.
To learn more, see Reuse data with variables and environments in Postman.
To create a collection variable, open your collection’s Variables tab and add your variables.
To learn more, see Store and reuse values using variables.
An environment is a set of variables specific to a context. For example, you can create two environments, one for your sandbox environment and one for production. Then, you can create variables where you expect the value to be different for each environment, such as an API key. When your API consumer switches environments, the value switches for them.
To create an environment, in the left sidebar, click Add >
Environment. Then, add your variables.
To learn more, see Group sets of variables in Postman using environments.
If an API consumer forks your collection and you’ve pinned environments to it, by default, the API consumer also forks your pinned environment.
To pin environments to your collection, open your collection. In the Postman workbench, click the environment selector. Then, hover over the environment and click Pin to collection. Repeat for each collection and environment combination.
You can set one pinned environment as the default pinned environment for your collection. When an API consumer forks a collection that has a default pinned environment, Postman automatically makes it the active environment in their forked collection.
To learn more, see Pin environments to collections.
You can use pre-request and post-response scripts to enhance your API consumer’s developer experience. You can write scripts to automate tasks, transform data, add conditional logic, and give your API consumers immediate feedback, such as how to address errors.
For example, you can write a script that formats dates to the API’s expected format, or validates whether a response’s key-value pair is present. If your API uses access tokens, you can write a script that takes the token from a response and uses it in later requests.
To learn more, see Test APIs and write scripts in Postman.
Open a request, folder, or collection. Then open the Scripts tab. Choose Pre-request or Post-response and write your script.
To learn more, see Use scripts to add logic and tests to Postman requests.