Postman Enterprise users can add tags to collections, workspaces, and APIs. You can use tags to improve organization, collaboration, documentation, discoverability, and productivity.
You can manually manage element tags in Postman, but did you know that you can do it programmatically with the Postman API? With the API, you can manage your collection, API, and workspace tags. You can also search for elements by tag. This endpoint’s response contains a paginated list of elements with the given tag. We use cursor pagination on this endpoint, and you can also filter your search by workspace, collection, or API.
With these endpoints, you can:
- Add an under-review tag to an API when you create a new version with the Postman API. You can then share this tag with your stakeholders so they can easily filter elements that contain that tag.
- Get all APIs containing the under-review tag and send them to a Slack channel.
- Automate clean up tasks. With the Postman API you can delete all elements (workspaces, APIs, and collections) that contain a specific tag, like to-delete.
- If a monitor fails, mark its collection with a tag so it’s easily found.
- … and more!
A collection that deletes elements with a specific tag
We’ve created a Delete Postman Elements by Tag collection that deletes any collections, APIs, and workspaces that contain a given tag. The collection uses the GET /tags/{slugId}/entities
endpoint, then uses the DELETE endpoints for workspaces, collections, and APIs. Basically, it gets all elements containing the tag, then iterates on deleting collections, APIs, and workspaces in different requests in the collection:
To delete all elements with a specific tag, open the collection’s Variables tab, enable the tag variable and provide the tag you want to use, then run the collection:
The collection run results will display. If the collection finds an element with the given tag (like the delete tag), you’ll see that the collection deleted the elements that had the given tag:
How are you using tags in Postman?
This is just one example of how you can automate your tag management with the Postman API and add value to your development process. Do you have a specific use case? How would you use the Postman API in your development process to tag your elements and work with these tags? Let us know about your use cases!