# Retrieving Mock ID via script

**URL:** <https://community.postman.com/t/retrieving-mock-id-via-script/1461>\
**Category:** Help Hub\
**Tags:** mocks\
**Created:** [April 20, 2018, 10:06pm UTC](https://community.postman.com/t/retrieving-mock-id-via-script/1461 "2018-04-20T22:06:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Codejockey7](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Codejockey7](https://community.postman.com/u/Codejockey7)\
**Post date:** [April 20, 2018, 10:06pm UTC](https://community.postman.com/t/retrieving-mock-id-via-script/1461/1 "2018-04-20T22:06:31Z")

</div>

Hi,  
Since Adding a mock always generate a new ID (eg.  
_[https://a4c72e3c-4er4-e444-874e-5df4233f9a6.mock.pstmn.io](https://a4c72e3c-4er4-e444-874e-5df4233f9a6.mock.pstmn.io)_), is it possible to retrieve that ID and feed it into the environment variable somehow rather than just manually doing it ?  
Any suggestions ?

---

<div class="post-metadata">

**Author:** ![Codejockey7](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Codejockey7](https://community.postman.com/u/Codejockey7)\
**Post date:** [April 24, 2018, 4:25pm UTC](https://community.postman.com/t/retrieving-mock-id-via-script/1461/2 "2018-04-24T16:25:03Z")

</div>

Found it! You can use the postman API ([https://api.getpostman.com/mocks](https://api.getpostman.com/mocks)) to get all the mocks and drill down to find the mockUrl you are looking for
