Postman API Testing Cheat Sheet
A reference for building requests, using variables, writing test scripts, and running collections in Postman.
2 PagesIntermediateFeb 20, 2026
Core Concepts
Building blocks of a Postman workspace.
- Collection- A folder of saved requests that can be organized, shared, and run together
- Environment- A named set of variables (e.g. dev, staging, prod) swapped without editing requests
- Variable scopes- Global, collection, environment, and local variables, resolved in that precedence order
- Pre-request script- JavaScript that runs before the request is sent (e.g. to set a timestamp or token)
- Tests tab- JavaScript assertions that run after the response is received
- Runner- Executes an entire collection or folder sequentially, optionally with a data file
Using Variables
Referencing and setting variables in a request.
javascript
// In URL or body: {{base_url}}/users/{{userId}}// Pre-request script: set a variablepm.environment.set("timestamp", Date.now());// Read a variableconst token = pm.environment.get("authToken");// Set from response in Tests tabconst body = pm.response.json();pm.environment.set("authToken", body.token);
Test Scripts (pm.test)
Common assertions written in the Tests tab.
javascript
pm.test("Status code is 200", function () { pm.response.to.have.status(200);});pm.test("Response has id field", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property("id");});pm.test("Response time under 500ms", function () { pm.expect(pm.response.responseTime).to.be.below(500);});
Auth & Headers
Common authorization patterns used in requests.
javascript
// Bearer token header// Key: Authorization Value: Bearer {{authToken}}// Basic auth (Authorization tab -> Basic Auth)// username/password auto-encoded to base64// API key in header// Key: x-api-key Value: {{apiKey}}// Newman CLI: run a collection headlessly// newman run collection.json -e environment.json
Pro Tip
Chain requests by extracting a value (like an auth token or created resource ID) from one response into an environment variable in its Tests tab, then reference it with `{{variable}}` in later requests in the same collection run.
Was this cheat sheet helpful?
Explore Topics
#PostmanAPITesting#PostmanAPITestingCheatSheet#ToolsOthers#Intermediate#CoreConcepts#UsingVariables#TestScriptsPmTest#AuthHeaders#DataStructures#APIs#Testing#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance