Let the postman agent mode do the hard work and you’ll be surprise on the result
From the publisher’s feed, collected in the ZeroLabs newsroom.
Let the Postman Agent Mode Do The Hard Work and You’ll Be Surprise on the ResultPostman Agent Mode finally automates the “boring stuff” so we can get back to actually building.Source: Image generated by AIPostman is widely known for its versatility in the API world. It has now reached a milestone in the era of Artificial Intelligence (AI) with the release of its own agent which is called Agent Mode.Agent Mode completes tasks faster across collections, tests, workspaces, environments, monitors, and Spec Hub. Agent Mode can help create and manage requests, flows, and mock servers, and debug errors and write tests.It is an AI-powered assistant that can automate your API Lifecycle using natural language.How to use the agent mode?It is embedded directly in postman and can be found in the bottom-right corner of your screen. It is a chat interface that will let you send request as “prompts”.Take a look at this sample prompt:Create a postman collection from scratch. The collection must include two API. The first API is an authentication API that uses basic username and password and an API Key on the header parameter and return a 50 length long token. The second API will then used the return token from authentication API and has a body parameter of first name, last name, age and contact number and must return the following fields: Unique Identification, first name, last name, age, contact number, created date and time. The Endpoint must be dynamically adapted the values from the chosen Environments. The collection must also have the test request and response data. Include the complete test script (Positive and Negative Scenario) and security checking. After the collection, create three environments namely Development, Test and Production. Each environments has the following key — domain, endpoint, username, password and APIKey. Apply Colors for each environments — Blue for Development, Orange for Test and Green for Production. The collection and environment must be working on postman runner. Create a detailed documentation for the collection and environments. And as much as possible apply it to postman notebook. Prepare also the CICD pipeline using the postman newman.AI agent is like a waiter where you as a customer will provide your order request with a the specifics on how you want it done. You need to supply the context by defining what you wanted to achieve in a very specific manner.By sending the above prompt, it will generate a new collection of two post methods.Source: Image by the author.It also populated the necessary details like the Auth, Headers, Body and pre-req and post-res scripts.Source: Image by the author.It also generate the sample request and response in different scenario which is best for API’s intended for POC or Mock. With Postman built-in documentation, the agent mode easily translate the prompt to readable and understandable documentation.Source: Image by the author.Environments are also created that automatically masked the sensitive information. Although on this part, the environment colors aren’t implemented yet because currently, postman do not have an API that can be used by the agent to do the job. I wish agent mode can automate this as well.Source: Image by the author.The agent mode also able to prepare a github action yaml code for the CI/CD Pipeline along with the newman script.Newman script:npm install -g newman newman-reporter-htmlextra# Run against Development env (via Postman API access)newman run "https://api.getpostman.com/collections/21361434-0c3ee247-03cc-494e-9a59-7a3cfcb0fc66?apikey=YOUR_POSTMAN_API_KEY" \ -e "https://api.getpostman.com/environments/21361434-5840343c-5950-408a-8ac9-cd56af19aa8c?apikey=YOUR_POSTMAN_API_KEY" \ - reporters cli,htmlextra \ - reporter-htmlextra-export ./reports/report.htmlGithub Action:name: API Tests - Auth + Person APIon: push: branches: [main, develop] pull_request: branches: [main]jobs: api-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4- uses: actions/setup-node@v4 with: node-version: '20'- name: Install Newman run: npm install -g newman newman-reporter-htmlextra- name: Run Newman (Test) run: | newman run "https://api.getpostman.com/collections/21361434-0c3ee247-03cc-494e-9a59-7a3cfcb0fc66?apikey=${{ secrets.POSTMAN_API_KEY }}" \ -e "https://api.getpostman.com/environments/21361434-1bd1256a-94a2-4967-aa81-91c97e2a24ac?apikey=${{ secrets.POSTMAN_API_KEY }}" \ - reporters cli,htmlextra \ - reporter-htmlextra-export ./reports/newman-report.html- name: Upload report if: always() uses: actions/upload-artifact@v4 with: name: newman-report path: ./reports/Last but not the least, it also handle the creation of Notebook that is ready for publishing.Source: Image by the author.Source: Image by the author.Source: Image by the author.To make the output more structured, I used this follow-up prompt.Design a very detailed yet highly eye catchy and understandable Notebook that is ready to published.SummaryWithin a single or two prompts, the manual process of your API Lifecycle that takes days to weeks to month can now be done in minute/s.ConclusionWhat I can say is that Postman without the agent is already great and it became way more great when this agent mode release.What can you say about Postman Agent Mode? What do you already build using from it?View more information about this from Postman.https://learning.postman.com/docs/agent-mode/overviewLet the postman agent mode do the hard work and you’ll be surprise on the result was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.