Postman recommends maintaining your APIs in your public workspaces. This ensures your APIs are current on the Postman API Network, enabling you to share your latest changes with API consumers. There are multiple options for maintaining APIs in Postman that align with your organization's API development workflow.
If your API definitions and collections are stored in a remote code repository, such as GitHub, you can use version control to connect your API in Postman to the remote code repository.
When you're ready to share your API definitions and collections with your API's consumers, you can pull changes from the remote repository to bring changes into your public workspace in Postman. Learn more about syncing APIs between your public workspace and code repository.
If your collections are stored in a non-public workspace in Postman, such as a team workspace, you can use Postman's version control to fork the collection in a public workspace.
When you're ready to share your collections with your API's consumers, you can pull changes from the parent collection (in your non-public workspace) to the forked collection (in your public workspace).
If your collections are stored in a non-public workspace, such as a team workspace, you can use the Postman API to create a custom, automated workflow that publishes collections from a non-public workspace to a public workspace. You can learn how to make a request to the Postman API.
When you're ready to share your collections with your API's consumers, you can use code to create a GET
request that gets the collection you want to publish, then you can create a PUT
request that publishes the collection. Use the /collections/collection-id
endpoint to get and publish your collections.
You can also create and send the requests in a collection or flow.
To share a collection to a public workspace using the Postman API, do the following:
Create a collection (source collection) in a non-public workspace, and create another collection (destination collection) in a public workspace that's available on the Postman API Network.
Get the collection IDs for both collections. Select the information icon in the right sidebar, and copy the collection IDs.
Get a Postman API key in the team where your source collection is stored. If the destination collection is in a different team, you must also get a Postman API key in that team.
Create a GET
request to a collection in a non-public workspace that you want to publish. The request returns a collection object in the response body. The object contains details about the source collection you can use to publish it.
Use the following URL in your request:
https://api.getpostman.com/collections/source-collection-id
If you're sending the request from Postman, set the response as an environment variable and convert the response into a JSON string from the Post-response tab:
const response = pm.response.json();
pm.environment.set('sourceCollection', JSON.stringify(response));
Create a PUT
request to a collection in a public workspace that you want to publish to. Include the source collection object in the request body. The request publishes the source collection to the destination collection.
Use the following URL in your request:
https://api.getpostman.com/collections/destination-collection-id
In your requests, add an authorization header that uses X-API-Key
as the key and your Postman API key as the value. For more details, see the Postman API documentation.
If the destination collection is in a different team, make sure your
GET
andPUT
requests use Postman API keys created in their separate teams.
If you're sending the requests from Postman, it's recommended that you use your Postman Vault to store sensitive data as vault secrets. Only you can access and use values associated with your vault secrets, and vault secrets aren't synced to the Postman cloud. If you want to share sensitive data with collaborators, you can store it in an environment as a secret type variable.
Send the GET
request to return the source collection, then send the PUT
request to publish the source collection to the destination collection.
Last modified: 2023/11/03