Combine postman collections within the same workspace?

I’m trying to find an easier way to combine 2 API collections in the same team workspace . I am the owner of one of the collection which I would want to put in another collection in the same workspace in Postman Pro.

The Share action should allow you to share collections to different workspaces that are visible to you:

@Chris If my ask wasn’t clear- My API requests collection is already shared/part of team workspace. Now what I’m meaning to do is to combine this collection with another collection (which is in the same team workspace) so that all api requests are just part of 1 collection and not two separate ones. I do not want to share a collection in different workspace.

Ah, I see – totally misread that first post :sweat_smile:. There are three ways (that I can think of) to go about combining two collections.

Using the GUI
Individual requests and folders can be dragged and dropped into different collections within the same workspace. This is a bit clunky if there are a lot of individual requests in a collection.


Using the API
The Postman API is pretty great – you can update collections by sending a PUT request to the Update Collection endpoint with whatever information you’d like to update it within the request body. It’ll require some copy/pasting but here’s a generic overview of what the flow would look like:

  1. Generate a Postman API key - https://docs.api.getpostman.com/#authentication

  2. Retrieve all of your collections via the GET All Collections endpoint. Responses will look something like:

{
  "collections": [
    {
      "id": "dac5eac9-148d-a32e-b76b-3edee9da28f7",
      "name": "Cloud API",
      "owner": "631643",
      "uid": "631643-dac5eac9-148d-a32e-b76b-3edee9da28f7"
    },
    {
      "id": "f2e66c2e-5297-e4a5-739e-20cbb90900e3",
      "name": "Sample Collection",
      "owner": "631643",
      "uid": "631643-f2e66c2e-5297-e4a5-739e-20cbb90900e3"
    },
    {
      "id": "f695cab7-6878-eb55-7943-ad88e1ccfd65",
      "name": "Postman Echo",
      "owner": "631643",
      "uid": "631643-f695cab7-6878-eb55-7943-ad88e1ccfd65"
    }
  ]
}
  1. Save the UIDs of the two collections you want to combine (not the id)

  2. Retrieve the collection that’s to be combined into the main collection (let’s call it C1) and save the response - the response will look something like:

{
  "collection": {
    "variables": [],
    "info": {
      "name": "Sample Collection",
      "_postman_id": "f2e66c2e-5297-e4a5-739e-20cbb90900e3",
      "description": "This is a sample collection that makes a tiny request to Postman Echo service to get the list of request headers sent by a HTTP client.",
      "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
    },
    "item": [
      {
        "id": "82ee981b-e19f-962a-401e-ea34ebfb4848",
        "name": "Request Headers",
        "event": [
          {
            "listen": "test",
            "script": {
              "type": "text/javascript",
              "exec": "var responseJSON;\ntry {\n    tests[\"Body contains headers\"] = responseBody.has(\"headers\");\n    responseJSON = JSON.parse(responseBody);\n    tests[\"Header contains host\"] = \"host\" in responseJSON.headers;\n    tests[\"Header contains test parameter sent as part of request header\"] = \"my-sample-header\" in responseJSON.headers;\n}\ncatch (e) { }\n\n\n\n"
            }
          }
        ],
        "request": {
          "url": "https://echo.getpostman.com/headers",
          "method": "GET",
          "header": [
            {
              "key": "my-sample-header",
              "value": "Lorem ipsum dolor sit amet",
              "description": ""
            }
          ],
          "body": {
            "mode": "formdata",
            "formdata": []
          },
          "description": ""
        },
        "response": []
      }
    ]
  }
}
  1. Retrieve the collection you’d like to combine everything into (Let’s call it C2) using the GET Single Collection endpoint and save that response as well.

  2. Create a PUT request to the Update Collection endpoint (this will update C2). In the body of the request, add C2’s response and add all of the items you’d like from C1 (Items are individual requests or folders).


Stitch the JSON Together
Export the two collections from the app – they’ll be downloaded as JSON files. Inspect the two JSON files and copy/paste any of the items you want from one collection to the other and re-import back into the app. The important thing here is to make sure that you’re following the schema for the particular collection version you’re using.


That’s a whole lotta information so feel free to send over any other questions you may have. The Postman API documentation page has a Run in Postman button on the top right that’ll allow you to import the API collection directly into the app to use.

2 Likes

Thank you @Chris yea apparently I was struggling with moving/drag the folders from my collection to another because I was trying to move the parent/main collection. But it worked when individually moved inner folders in that collection one by one. Thanks!