# Run Test cases using an API endpoint

**URL:** <https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374>\
**Category:** Help Hub\
**Created:** [March 6, 2019, 9:50am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374 "2019-03-06T09:50:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jalib.khan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jalib.khan/32/1399_2.png) [@jalib.khan](https://community.postman.com/u/jalib.khan)\
**Post date:** [March 6, 2019, 9:50am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/1 "2019-03-06T09:50:37Z")

</div>

I am looking for an endpoint that can run all the test cases I have created in postman

Is it possible?

I am not looking for the option of monitoring as I have already tried that but that’s not a good approach

---

<div class="post-metadata">

**Author:** ![prashant\_postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/prashant_postman/32/25_2.png) [@prashant\_postman](https://community.postman.com/u/prashant_postman)\
**Post date:** [March 6, 2019, 9:52am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/2 "2019-03-06T09:52:41Z")

</div>

@jalib.khan Can you explain the use case that you are unable to solve using Postman Monitors.

---

<div class="post-metadata">

**Author:** ![jalib.khan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jalib.khan/32/1399_2.png) [@jalib.khan](https://community.postman.com/u/jalib.khan)\
**Post date:** [March 6, 2019, 9:55am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/3 "2019-03-06T09:55:07Z")

</div>

Basically I can use monitors but the case is that I can’t use it because I have to create a monitor for every collection  
I wanted to know if there’s an endpoint to run all the test cases in a collection

---

<div class="post-metadata">

**Author:** ![prashant\_postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/prashant_postman/32/25_2.png) [@prashant\_postman](https://community.postman.com/u/prashant_postman)\
**Post date:** [March 6, 2019, 9:57am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/4 "2019-03-06T09:57:34Z")

</div>

@jalib.khan I don’t think we support this feature. In Postman you can only run tests inside one collection and for that either you can use Postman Runner, Newman or Monitors.

---

<div class="post-metadata">

**Author:** ![jalib.khan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jalib.khan/32/1399_2.png) [@jalib.khan](https://community.postman.com/u/jalib.khan)\
**Post date:** [March 6, 2019, 9:58am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/5 "2019-03-06T09:58:29Z")

</div>

@prashant_postman Thanks for your help

---

<div class="post-metadata">

**Author:** ![postman-paul540](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/postman-paul540/32/149_2.png) [@postman-paul540](https://community.postman.com/u/postman-paul540)\
**Post date:** [March 6, 2019, 10:40am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/6 "2019-03-06T10:40:18Z")

</div>

You can run all the tests inside a collection by using the Postman Pro API with Newman.

[https://docs.api.getpostman.com/](https://docs.api.getpostman.com/)

You’ll need to create a Postman Pro API Key in order to use this.

So, I can type in the below into a command terminal (or create a .bat file which will run the tests upon double clicking it)

```auto
newman run "https://api.getpostman.com/collections/{{putYourTestCollectionIDHere}}/?apikey={{postmanProAPIKeyGoesHere}}" --environment "https://api.getpostman.com/environments/{{putYourEnvironmentIDHere}/?apikey={{postmanProAPIKeyGoesHere}}"

```

This way, you can also trigger the running of your tests in your build tool (TeamCity, Jenkins, TravisCI etc.)

---

<div class="post-metadata">

**Author:** ![deepak.pathania](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@deepak.pathania](https://community.postman.com/u/deepak.pathania)\
**Post date:** [March 26, 2019, 6:42am UTC](https://community.postman.com/t/run-test-cases-using-an-api-endpoint/4374/7 "2019-03-26T06:42:27Z")

</div>

@postman-paul540 That is a great answer.

To add on to that, you could probably arrange similar collections in a workspace in Postman to help you segregate which collections to run at a time.

So let’s say you have a `Project X`, and all collections related to that project are in a workspace. You could then use the Postman API, to fetch that individual workspace. Here’s what the response looks like:

```javascript
{
  "workspace": {
    "id": "f8801e9e-03a4-4c7b-b31e-5db5cd771696",
    "name": "Demo workspace",
    "type": "personal",
    "description": "Demos.",
    "collections": [
      {
        "id": "7c31b469-bd43-4411-9283-6d397855ee0e",
        "name": "Mock demo - collection",
        "uid": "1234-7c31b469-bd43-4411-9283-6d397855ee0e"
      },
      {
        "id": "356fe068-a0f8-4f31-b34d-d12149eac681",
        "name": "Mock demo - response code",
        "uid": "1234-356fe068-a0f8-4f31-b34d-d12149eac681"
      }
    ],
    "environments": [
      {
        "id": "423fd955-a9c8-47cd-9ab0-09a6a575c4be",
        "name": "Mock demo - CNX",
        "uid": "1234-423fd955-a9c8-47cd-9ab0-09a6a575c4be"
      },
      {
        "id": "24c45c84-5147-4c15-bb9a-c3186b81d3cc",
        "name": "Mock Demo - response code",
        "uid": "1234-24c45c84-5147-4c15-bb9a-c3186b81d3cc"
      }
    ]
  }
}

```

You could then iterate over the `workspace.collections` array to run all those collections by extracting the id from there.

Hope this helps.
