Postman
Postman is a desktop and web API client. You build HTTP requests in a form, group them into collections, switch environments with variables, write JavaScript tests, and run the whole set from the Collection Runner or a CI pipeline. Recent versions also speak WebSocket, gRPC, GraphQL and MQTT. This chapter follows the current Postman UI (v12), where the sidebar has Items and new tabs open with the Add (+) button.
| Key fact | Details |
|---|---|
| Install | Desktop app for Windows, macOS and Linux from postman.com, or the web app with the Postman Desktop Agent |
| Plans | A free plan exists. Collaboration features and usage limits depend on the plan, so check the current pricing page |
| Best for | Exploratory API testing, chained requests, contract checks, sharing ready-made requests with a team |
| Command line | Postman CLI (recommended by Postman) or Newman |
Request → save to a collection → move URLs and secrets into environment variables → add authorization at collection level → add post-response tests → run the collection (Runner / Postman CLI / Newman) → read the report → fix or file a bugSending a request: method, URL, params, headers and body
- Click Add (+) next to the open tabs and choose an HTTP request.
- Pick a method from the dropdown (
GET,POST,PUT,PATCH,DELETE...) and enter the URL, for examplepostman-echo.com/get. - Open Params and add query parameters as key/value rows. Postman keeps the URL in sync, so
?page=2&size=20appears automatically. - Open Headers to add headers such as
Accept: application/json. Click hidden to see the headers Postman adds by itself (User-Agent,Postman-Token,Content-Length...). - For
POST/PUT/PATCH, open Body and choose a type: raw → JSON for APIs, form-data for file uploads, x-www-form-urlencoded for classic forms. - Click Send. The response pane shows the status code, time and size, plus the Body (Pretty / Raw / Preview), Cookies, Headers and Test Results tabs.

QA tip: Hover over the response time to see the breakdown into DNS lookup, TCP handshake, SSL handshake, waiting for the first byte and download. That breakdown is good evidence for "the API is slow" reports.
Collections, environments and variables
A collection is a folder tree of saved requests. An environment is a named set of variables, such as local, stage and prod, that you switch with one click.
- Save a request with
Ctrl+S/Cmd+S→ New Collection, give it a name and click Save. - Create an environment: click Add (+) in the sidebar → Environments, or use the environment selector at the top right of the workbench.
- Add variables such as
baseUrl,userEmailandapiKey. Click Secure next to the name for anything sensitive. - Replace hard-coded values with variables in double curly braces:
{{baseUrl}}/users/{{userId}}. Variables work in the URL, params, headers and body. - Make the environment active: pick it in the selector at the top right, or click Set active next to it in the Environments list. Hover over
{{baseUrl}}to see which value will be used.

Each variable has a local value and an optional shared value. The local value is what Postman uses to send requests. It isn't synced to the Postman cloud and teammates don't see it. The shared value syncs to the workspace, so never put real tokens or passwords there.
If the same name exists in several scopes, the narrowest one wins. Environment variables override collection and global variables, and data-file and local variables override environment values.
Caveat: Name environments so that production is impossible to miss, and give production a red color. A collection run against the wrong environment is a classic way to create test data in production.
Authorization: Bearer, Basic, API key, OAuth 2.0 and inheritance
- Open the collection (click its name) → Authorization tab.
- Choose a type: Bearer Token, Basic Auth, API Key (header or query parameter), OAuth 2.0 and others.
- Use variables rather than literal values, for example token
{{accessToken}}. - In each request's Authorization tab, leave Inherit auth from parent. Every request then uses the collection settings, and you change the token in one place.
- For OAuth 2.0, fill in the grant type, auth URL, token URL, client ID and scopes, then click Get New Access Token. Postman stores the token, and you can refresh it when it expires.
For negative tests, duplicate a request and set its Authorization to No Auth (expect 401), or use an expired or low-privilege token (expect 401 or 403).
Scripts: pre-request setup and post-response tests
Each request, folder and collection has a Scripts tab with two editors: Pre-request (runs before sending) and Post-response (runs after the response arrives). Scripts are JavaScript using the pm object.
- Open a request → Scripts → Post-response.
- Click Snippets at the lower right of the editor and choose, for example, Status code: Code is 200.
- Add your own checks with
pm.testandpm.expect. The examples below cover the most common ones. - Click Send and open Test Results in the response pane. Use Filter Results to show Passed, Skipped or Failed.
- Open Console from the footer to see
console.log()output and the raw request and response for each call.
pm.test("Status is 201", () => {
pm.response.to.have.status(201);
});
pm.test("Response time under 800 ms", () => {
pm.expect(pm.response.responseTime).to.be.below(800);
});
const body = pm.response.json();
pm.test("Created user has an id and the right email", () => {
pm.expect(body.id).to.be.a("number");
pm.expect(body.email).to.eql(pm.environment.get("userEmail"));
});
// Save a value for the next request in the chain
pm.environment.set("userId", body.id);A Pre-request script prepares data, for example a unique email for every run:
pm.environment.set("userEmail", `qa+${Date.now()}@example.test`);QA tip: Keep tests about the contract: status, required fields, types and business rules. Comparing the full body to a stored copy breaks on every harmless change, such as a new field or a different order.
Collection Runner, Postman CLI and Newman
Collection Runner (inside the app):
- Click Items in the sidebar → Collections, select a collection or folder, and click Run.
- Under Run type, choose Functional, then Local.
- Choose the environment at the upper right.
- Set Iterations. Under Iteration data, pick a Datafile (CSV or JSON) to run the same requests with different input rows. Each column becomes a
{{variable}}. - In Settings, add a delay between requests and decide whether to Stop run if an error occurs.
- Drag requests to change the order, or untick the ones to skip, then click Start run.
- Read the results: passed and failed tests per request, an Errors tab for runtime errors, and Console log for script output. In the desktop app, use View more actions → Export run results.

In CI, Postman recommends the Postman CLI. Install it with npm install -g postman-cli, and use Configure CI/CD in the Runner to generate the exact command for your workspace. Postman has announced that Newman won't receive further updates or fixes. Many pipelines still use it, though, and it runs exported collection files with no account at all:
npm install -g newman
newman run my-collection.json -e stage.postman_environment.json \
-d users.csv -n 3 --bail -r cli,junit--bail stops at the first failed test and makes Newman exit with code 1, so the CI job fails. -r junit writes a JUnit XML report that most CI servers can display.
WebSocket, gRPC, GraphQL and MQTT requests
The Add (+) menu offers request types beyond HTTP:
- WebSocket: enter a
wss://URL, click Connect, write a message in Message and click Send. Incoming and outgoing frames appear in a timeline. This is useful for chat, notifications and live dashboards. - gRPC: enter the server address, load the service definition (server reflection or an imported
.protofile), pick a method, edit the message and click Invoke. - GraphQL: Postman fetches the schema, so you can build the query with autocomplete and set variables in a separate pane.
- MQTT: the steps below.
MQTT in Postman:
- Click Add and select MQTT.
- Enter the broker address, for example the public test broker
broker.hivemq.com, and click Connect. In the web app this needs the Postman Desktop Agent. - Open Topics, enter a topic such as
gimmejob/qa-lab/#, and turn on Subscribe. - Open Message, enter a topic such as
gimmejob/qa-lab/sensor1and a payload such as{"temp": 21.5}, then click Send. Because you're subscribed, the message appears twice: once outgoing and once incoming.

Caveat: Public brokers are visible to everyone. Use a unique topic prefix and never publish real data. The MQTT chapter of this path covers QoS, retained messages and Last Will in depth.
Sharing, code snippets and Git-friendly alternatives
- Import: paste a cURL command, an OpenAPI file or a HAR-derived request and Postman builds the request for you. This is the fastest way to turn DevTools' Copy as cURL into a saved request.
- Code (
</>icon in the right sidebar): generates the same request as cURL, Pythonrequests, JavaScriptfetchand other languages. It's a quick start for an automated test. - Export: collections export as JSON (Collection v2.1) and environments as separate JSON files. Remove secrets before you commit or send them.
- Bruno is a free, open-source alternative that stores each request as a plain-text file in your repository. Request changes can then be reviewed in pull requests next to the code.
Cheat sheet
| Task | How |
|---|---|
| New request | Add (+) → HTTP |
| Save to a collection | Ctrl+S / Cmd+S |
| Use a variable | {{baseUrl}} |
| Switch environment | Selector at the top right |
| One auth for all requests | Collection → Authorization, requests → Inherit auth from parent |
| Assert status | pm.response.to.have.status(200) |
| Save a value | pm.environment.set("token", value) |
| Debug scripts | Footer → Console |
| Data-driven run | Runner → Iteration data → CSV/JSON |
| CI run | Postman CLI or newman run collection.json -e env.json --bail |
| From browser to Postman | DevTools Copy as cURL → Postman Import |
Summary
- Build a request in the form, save it to a collection, and move every URL, user and secret into environment variables.
- Set authorization once on the collection, and keep post-response tests focused on status, required fields and business rules.
- Chain requests by saving values with
pm.environment.set, and use the Collection Runner with a data file for data-driven checks. - Run collections in CI with the Postman CLI or Newman. Remember that Postman can also test WebSocket, gRPC, GraphQL and MQTT APIs.