# Same test multiple API endpoints

**URL:** <https://community.postman.com/t/same-test-multiple-api-endpoints/56296>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [January 8, 2024, 10:20am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296 "2024-01-08T10:20:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![satellite-pilot-5611](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@satellite-pilot-5611](https://community.postman.com/u/satellite-pilot-5611)\
**Post date:** [January 8, 2024, 10:20am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/1 "2024-01-08T10:20:37Z")

</div>

> I have multiple APIs which have same response format.  
> I want to be able to run that same test on multiple APIs.  
> I don’t want to go to each API endpoint and write the same test in tests tab of Postman.  
> Any soultion for this!!

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2024, 10:33am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/2 "2024-01-08T10:33:16Z")

</div>

Hey @satellite-pilot-5611 👋

Welcome to the Postman Community! :postman:

You can write the test at the Collection level and that will run against each request. This can also be done at the Folder level too, just in case some of the request return a different format and you need to seperate them out.

As an example, this test at the Collection level would run each time you send a request to check the status code:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/8/78c80e24983546448809442b2e5def88cf965c7c.png)

---

<div class="post-metadata">

**Author:** ![satellite-pilot-5611](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@satellite-pilot-5611](https://community.postman.com/u/satellite-pilot-5611)\
**Post date:** [January 8, 2024, 10:59am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/3 "2024-01-08T10:59:02Z")

</div>

Thank you so much, I have been searching for a solution online for atleast 2 hours. I got the answer from here within an hour. 😀

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2024, 11:03am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/4 "2024-01-08T11:03:41Z")

</div>

Happy to help! 🏆

I would also recommend taking a look through our learning centre (Direct link to this in the header bar on the right).

We have various sections which cover the core functionality of the platform as well as links out to other helpful resources.

Here’s more about the scripts and the execution order:

> **[Scripting in Postman | Postman Learning Center](https://learning.postman.com/docs/writing-scripts/intro-to-scripts/#execution-order-of-scripts)**
>
> Scripting in Postman: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![satellite-pilot-5611](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@satellite-pilot-5611](https://community.postman.com/u/satellite-pilot-5611)\
**Post date:** [January 8, 2024, 11:09am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/5 "2024-01-08T11:09:05Z")

</div>

I have wrote a test at the folder level, but now I want that test not to be applicable for a particular endpoint.

When we run the folder we can skip a particular endpoint, but if we automate the testing process how to skip that end point.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2024, 11:21am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/6 "2024-01-08T11:21:22Z")

</div>

I need to see what you’re doing to “_skip_” the endpoint. I don’t know what you have in front of you 😃

From a very basic point of view, you could just tell it to only run the test if the request doesn’t match:

```auto
if(pm.info.requestName !== "Request_Name") {
    pm.test("Status code is 200", function () {
        pm.response.to.have.status(200);
    });
}

```

It could also be something like this if you need to show a test is skipped for the request:

```auto
let skipTest = pm.info.requestName === "Request_Name";

(skipTest ? pm.test.skip : pm.test)("Check status code", () => {
    pm.expect(pm.response.code).to.equal(200);
});

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [January 11, 2024, 11:21am UTC](https://community.postman.com/t/same-test-multiple-api-endpoints/56296/7 "2024-01-11T11:21:25Z")

</div>

Closed on January 11, 2024, 11:21am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
