# How to run postman requests using Tags

**URL:** <https://community.postman.com/t/how-to-run-postman-requests-using-tags/20628>\
**Category:** Help Hub\
**Tags:** newman-project, tests, variables, collections\
**Created:** [February 21, 2021, 1:30pm UTC](https://community.postman.com/t/how-to-run-postman-requests-using-tags/20628 "2021-02-21T13:30:32Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [February 21, 2021, 1:30pm UTC](https://community.postman.com/t/how-to-run-postman-requests-using-tags/20628/1 "2021-02-21T13:30:32Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

# Get all requests in the collection:

**you can also get information about all the requests in a collection by using :**

[https://api.getpostman.com/collections/{{collection\_UUID}}](https://api.getpostman.com/collections/%7B%7Bcollection_UUID%7D%7D)

**to get uuid and api key goto :**

[https://app.getpostman.com](https://app.getpostman.com/)

**Now for generating api key \>**

goto account settings \> api key and generate api key.

to get collection uuid goto specific workspace and collection and copy the uuid part from url:

![Image for post](https://miro.medium.com/max/1211/0*bS-1YwXf4GI2gaii.png)

**Note:** you can also get UUID by clicking collection and clicking info panel on the right side

![Image for post](https://miro.medium.com/max/397/1*mFhKG_cmjgxkRIcr6FXLNQ.png)

# Now in your collection

**Rename all requests as:**

```
get user details [Regression][Smoke][Somethingelse]
get account details [Regression]

```

# Then Create a new request called initial request and keep it as the first request in your collection:

**url:** [https://api.getpostman.com/collections/8xxxxtheuuidyoucopied](https://api.getpostman.com/collections/8xxxxtheuuidyoucopied)

**authorization:** apikey-header : key: X-Api-Key and value: yourapikey

**test-script** :

```
pm.environment.unset("requestToRun")
reqeustlist = pm.response.json().collection.item.map((a) => a.name)
requestToRun = reqeustlist.filter((a) => a.includes(pm.environment.get("tag")))
let val = requestToRun.pop()
pm.environment.set("requestToRun", requestToRun)
val ? postman.setNextRequest(val) : postman.setNextRequest(null)

```

Now set the envirnoment variable as what you want to look for eg: run script that contains text “Regression” then set `pm.environment.set("tag","Regression")`

**Now in your collection-pre-request add:**

```
if (pm.info.requestName !== "initial request") {
let requestToRun = pm.environment.get("requestToRun")
let val = requestToRun.pop()
pm.environment.set("requestToRun", requestToRun)
val ? postman.setNextRequest(val) : postman.setNextRequest(null)
}

```

# Output:

![Image for post](https://miro.medium.com/max/1335/0*upq4hlWWr7tvvOUo.png)

Ran only reqeusts that has “Copy” in its name

# Example collection:

[https://www.getpostman.com/collections/73e771fe61f7781f8598](https://www.getpostman.com/collections/73e771fe61f7781f8598) , you can click ctrl+o and choose link to import this collection

**Note:** In newman you can pass the environment variable as “ — env-var tag=Regression”

---

_[View the full topic](https://community.postman.com/t/how-to-run-postman-requests-using-tags/20628)._
