liminfo

Postman Reference

Free reference guide: Postman Reference

29 results

About Postman Reference

The Postman Reference is a structured, searchable guide covering all major aspects of API testing and development with Postman. It spans six key areas: HTTP request methods (GET, POST, PUT, PATCH, DELETE), collection management (creating, running, and exporting collections), variable scoping (global, collection, environment, and dynamic variables), test scripting with pm.test() and pm.expect(), environment configuration for dev/staging/production, and automation with Newman CLI and CI/CD integration.

Backend developers, QA engineers, and API integrators rely on this reference when building and testing REST APIs. Whether you are setting up environment variables with `pm.environment.set()`, writing JSON schema validation tests, running a collection with Newman in GitHub Actions, or configuring monitors for scheduled API health checks, this reference provides the exact syntax and practical examples you need.

The reference is organized into six categories — Requests, Collections, Variables, Tests, Environments, and Automation — reflecting the natural workflow of API development in Postman. Each entry shows the Postman UI action or JavaScript code snippet with a realistic example. It covers Postman Collection v2.1 format, pre-request scripts, dynamic variables like `{{$randomEmail}}` and `{{$guid}}`, and the Postman API for programmatic workspace management.

Key Features

  • HTTP request methods: GET, POST, PUT, PATCH, DELETE with headers and JSON body examples
  • Collection management: create, run (Collection Runner with iterations/delay), export as v2.1 JSON
  • Variable scoping hierarchy: Global > Collection > Environment > Local with pm.globals/collectionVariables/environment API
  • Built-in dynamic variables: {{$randomInt}}, {{$randomEmail}}, {{$timestamp}}, {{$guid}}
  • Test scripting with pm.test(), pm.expect() Chai assertions, and pm.response object access
  • JSON Schema validation using pm.response.to.have.jsonSchema() for response structure testing
  • Newman CLI automation: run collections from terminal, generate HTML reports, integrate into CI/CD
  • Postman Monitors for scheduled API health checks with email alerts on failure

Frequently Asked Questions

What is Postman and what is it used for?

Postman is an API platform for building, testing, and documenting REST, GraphQL, and SOAP APIs. It provides a GUI for sending HTTP requests, organizing them into collections, writing automated tests, managing environments for different deployment stages, and running tests in CI/CD pipelines via Newman CLI.

What is the difference between Global, Collection, and Environment variables in Postman?

Global variables are accessible across all collections in your workspace. Collection variables are scoped to a single collection and shared among all requests within it. Environment variables are tied to a specific environment (Development, Staging, Production) and change when you switch environments. Use `{{variable_name}}` syntax to reference any of them in URLs, headers, or body.

How do I write a test to validate a JSON response in Postman?

In the Tests tab of a request, use pm.test() with pm.expect() for assertions: `pm.test("Status is 200", () => { pm.response.to.have.status(200); });`. For structure validation, use pm.response.to.have.jsonSchema(schema) with a JSON Schema object defining required fields and their types.

What is Newman and how do I use it for CI/CD?

Newman is the command-line runner for Postman collections. Install it with `npm install -g newman`, then run `newman run collection.json -e environment.json`. In CI/CD (e.g., GitHub Actions), add a step that runs Newman against your exported collection and environment files, optionally using `--bail` to fail the build on test failures.

What is the difference between Initial Value and Current Value for environment variables?

Initial Value is synchronized when you share a collection or environment with your team and is stored in Postman's cloud. Current Value is stored locally only and never shared. Always put sensitive information like API keys and passwords in Current Value only to prevent accidental exposure to teammates.

How do I run all requests in a collection automatically?

Use the Collection Runner: click the "Run" button on a collection, then set the number of iterations and delay between requests. For automated runs, use Newman CLI: `newman run collection.json --iteration-count 5`. You can also pass a CSV or JSON data file with `--iteration-data` to test multiple data sets.

How do I use pre-request scripts to set dynamic values?

Pre-request scripts run before each request and can set environment variables dynamically. For example: `pm.environment.set("timestamp", Date.now())` or generate a signature for authenticated requests. Access the scripts in the "Pre-request Script" tab of a request or at the collection level to apply to all requests.

How do I set up a Postman Monitor for API health checks?

Monitors run your collection on a schedule without manual intervention. Go to Collection > Monitor > Create Monitor, choose the run frequency (e.g., every 1 hour), select the environment and region, and configure email alerts for failures. Monitors are useful for detecting API regressions in production.