Maintain APIs in your public workspace

Postman recommends maintaining your APIs in your public workspaces. This ensures your APIs are current on the Public 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.

Code repository

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.

Postman's version control

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).

The Postman API

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:

  1. 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 Public API Network.

  2. Get the collection IDs for both collections. Select the information icon Information icon in the right sidebar, and copy the collection IDs.

  3. 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.

  4. 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 Tests tab:

    const response = pm.response.json();
    
    pm.environment.set('sourceCollection', JSON.stringify(response));
    
  5. 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
    
  6. 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 and PUT requests use Postman API keys created in their separate teams.

    If you're sending the requests from Postman, you can store API keys as environment variables.

  7. 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