Postman Tutorial
- Curriculum Overview
- 1. Introduction to Postman
- 2. Sending Requests & Body Types
- 3. Environments & Variable Scopes
- 4. Collections & Folders
- 5. Writing API Tests & Assertions
- 6. Automated Collection Runner
- 7. Postman CLI: Newman
- 8. Integration with CI/CD Pipelines
- 9. Mock Servers
- 10. API Monitoring & Uptime Alerting
- 11. Collaborative Workspaces
- 12. Generating API Documentation
- 13. Designing APIs (OpenAPI / Swagger)
- 14. Advanced Authorization
- 15. Postman Flows & Best Practices
Postman Mastery: The Complete API Engineering, Testing & Automation Guide
Postman is the enterprise standard API platform used by over 30 million developers across 500,000 organizations worldwide. Far beyond a basic graphical HTTP client, Postman provides a complete lifecycle toolchain for designing, debugging, testing, documenting, and monitoring APIs. This comprehensive 15-chapter curriculum covers the physicalrequest execution lifecycle, variable scoping hierarchies, automated JavaScript test suites withpm.test() and Chai assertions, headless CI/CD execution via the Newman CLI, OAuth 2.0 authentication, and virtual Mock Servers.
Execute REST, GraphQL, WebSocket, gRPC, and SOAP requests with fine-grained header control, multipart uploads, and OAuth 2.0 token management.
Write powerful JavaScript test scripts using pm.test(), JSON schema validators (Ajv), and response time benchmarks to ensure zero regressions.
Run automated collection suites headlessly in GitHub Actions, GitLab CI, and Jenkins to catch broken endpoints before production release.
1. The Postman Request Execution Lifecycle
Whenever you click "Send" in Postman, the application executes a deterministic four-phase pipeline:
Pre-Request Script
Executes custom JS before network dispatch: dynamic variables, HMAC hashes, auth token refresh.
HTTP Network Dispatch
Transmits raw request over HTTP/HTTPS, handling cookies, proxy rules, and SSL certificates.
Response Deserialization
Captures status code, headers, response time, payload size, and parses JSON/XML body.
Tests Script Assertions
Runs assertions against the response, verifies status codes, checks schemas, and saves output variables.
2. The Postman Variable Scope Hierarchy
Postman manages variables across five distinct scopes. When resolving {{variable_name}}, narrower scopes always override broader scopes:
| Scope Level | Precedence | Lifetime & Availability | Primary Production Use Case |
|---|---|---|---|
| Global | Broadest (Lowest) | Available across all workspaces and collections | Base utility URLs, static API keys, general constants |
| Collection | Intermediate | Bound exclusively to one specific collection | Collection-wide authentication tokens, version headers |
| Environment | High | Bound to selected environment (Dev, Staging, Prod) | Server hostnames, environment-specific database credentials |
| Data (Iteration) | Very High | Supplied via CSV/JSON during Collection Runner runs | Data-driven automated test payloads (multi-user testing) |
| Local | Narrowest (Highest) | Temporary; exists only during single request execution | Loop counters, transient calculation variables in scripts |
3. Production Blueprint: Automated Test Script with JSON Schema Validation
A production-ready test script placed in the Postman Tests tab that verifies status codes, measures response latency, validates JSON schema contracts, and persists auth tokens:
// 1. Verify Status Code is 200 OK or 201 Created
pm.test("Status code is successful (200 or 201)", function () {
pm.expect(pm.response.code).to.be.oneOf([200, 201]);
});
// 2. Performance SLA: Response latency must be under 400ms
pm.test("Response latency SLA is under 400ms", function () {
pm.expect(pm.response.responseTime).to.be.below(400);
});
// 3. Verify Content-Type Header
pm.test("Content-Type header is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include("application/json");
});
// 4. Strict JSON Schema Validation
const userSchema = {
"type": "object",
"required": ["id", "email", "role", "isActive"],
"properties": {
"id": { "type": "string" },
"email": { "type": "string", "format": "email" },
"role": { "type": "string", "enum": ["ADMIN", "USER", "EDITOR"] },
"isActive": { "type": "boolean" }
}
};
pm.test("Response body matches strict User JSON schema", function () {
const jsonData = pm.response.json();
pm.expect(tv4.validate(jsonData, userSchema)).to.be.true;
});
// 5. Extract and Persist Token to Environment for Chained Requests
if (pm.response.code === 200) {
const responseData = pm.response.json();
if (responseData.token) {
pm.environment.set("auth_token", responseData.token);
console.log("Successfully refreshed auth_token for downstream requests.");
}
}4. Complete Curriculum Directory (15 Comprehensive Modules)
A structured roadmap covering basic requests, test automation, Newman CLI, mock servers, and API security.
Phase 1: Core Requests, Variables & Collections (Chapters 1–4)
Phase 2: Automated Testing, Collection Runner & Newman (Chapters 5–8)
Phase 3: Mock Servers, OpenAPI, Auth & Enterprise Patterns (Chapters 9–15)
Frequently Asked Questions: Advanced Postman API Engineering
Explore Related Tools
Hand-picked utilities and calculators related to this tool.
