# Collection download via API call

**URL:** <https://community.postman.com/t/collection-download-via-api-call/895>\
**Category:** Help Hub\
**Created:** [February 5, 2018, 8:40pm UTC](https://community.postman.com/t/collection-download-via-api-call/895 "2018-02-05T20:40:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimArmstrong](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@TimArmstrong](https://community.postman.com/u/TimArmstrong)\
**Post date:** [February 5, 2018, 8:40pm UTC](https://community.postman.com/t/collection-download-via-api-call/895/1 "2018-02-05T20:40:54Z")

</div>

I’m hoping to use Newman in a Jenkins pipeline to run a Collection.

To that end I want to download the collection from Postman to a local filesystem on my CICD server.

I have read the article at [Integrate your Postman tests with Jenkins using Newman | Postman Docs](https://www.getpostman.com/docs/postman/collection_runs/integration_with_jenkins) but it looks like the collection files are already in place which isn’t going automatically pickup changes in my Team Collections.

So to reiterate how do I programatically download a collection. Is there an API for this. In fact is there an API for managing Collections in general.

BTW we are using Postman Pro.

---

<div class="post-metadata">

**Author:** ![ankit-m](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/ankit-m/32/979_2.png) [@ankit-m](https://community.postman.com/u/ankit-m)\
**Post date:** [February 6, 2018, 7:38am UTC](https://community.postman.com/t/collection-download-via-api-call/895/2 "2018-02-06T07:38:01Z")

</div>

Hi @TimArmstrong,

1. You can use the Postman API to download the collection JSON [https://docs.api.getpostman.com/#647806d5-492a-eded-1df6-6529b5dc685c](https://docs.api.getpostman.com/#647806d5-492a-eded-1df6-6529b5dc685c). This returns the latest data which is synced.
2. Save the response in a file `<filename>`
3. Finally, you can run the latest collection using `newman run <filename>`

Hope, this helps.

---

<div class="post-metadata">

**Author:** ![TimArmstrong](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@TimArmstrong](https://community.postman.com/u/TimArmstrong)\
**Post date:** [February 6, 2018, 9:59pm UTC](https://community.postman.com/t/collection-download-via-api-call/895/3 "2018-02-06T21:59:42Z")

</div>

Hello Ankit,

Ok that worked a treat.

Will update my question when I get everything working.

Tim

---

<div class="post-metadata">

**Author:** ![abhinav](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/abhinav/32/8_2.png) [@abhinav](https://community.postman.com/u/abhinav)\
**Post date:** [February 6, 2018, 11:24pm UTC](https://community.postman.com/t/collection-download-via-api-call/895/4 "2018-02-06T23:24:24Z")

</div>

@ankit-mI don’t think there is a need to save the response as a file. You should be able to directly call the API using newman run .

---

<div class="post-metadata">

**Author:** ![TimArmstrong](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@TimArmstrong](https://community.postman.com/u/TimArmstrong)\
**Post date:** [February 7, 2018, 2:28am UTC](https://community.postman.com/t/collection-download-via-api-call/895/5 "2018-02-07T02:28:08Z")

</div>

Hello Abhinav,

So I tried a few things but couldn’t get things to work as a one line command.

Last failed attempt was

newman run [https://api.getpostman.com/collections/](https://api.getpostman.com/collections/)…

Tim

---

<div class="post-metadata">

**Author:** ![\_pjoshi\_126](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/_pjoshi_126/32/44_2.png) [@\_pjoshi\_126](https://community.postman.com/u/_pjoshi_126)\
**Post date:** [February 7, 2018, 1:52pm UTC](https://community.postman.com/t/collection-download-via-api-call/895/6 "2018-02-07T13:52:11Z")

</div>

@TimArmstrong You can follow the [link](https://github.com/postmanlabs/newman#using-newman-with-the-postman-pro-api) to call Postman Pro APIs to fetch the collections and environments (If required for Newman run) at the time of Newman run. (No need to store them in any file)

Few points:-

1. You are required to have a valid API key to fetch collection/environments
2. The `uid` is the `user_id-collection_id` which you have to provide to fetch the specific collection for Newman run.

Hope this is what you are looking for.

---

<div class="post-metadata">

**Author:** ![TimArmstrong](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@TimArmstrong](https://community.postman.com/u/TimArmstrong)\
**Post date:** [February 8, 2018, 5:58am UTC](https://community.postman.com/t/collection-download-via-api-call/895/7 "2018-02-08T05:58:47Z")

</div>

Hello Prakhar,

So it’s working now.

newman run “[https://api.getpostman.com/collections/9999999-3d5e3244-9408-efbb-7767-999999999999?apikey=99999999999999999999999999999999](https://api.getpostman.com/collections/9999999-3d5e3244-9408-efbb-7767-999999999999?apikey=99999999999999999999999999999999)” -e DEV1\_Environment.json

My problem was I had not wrapped my URL in double quotes and so I suspect the shell was helping me by further interpreting my command and make a mess of things.

Tim
