postman-cli
v1.90.0
Published
Official Postman CLI - Command-line companion for API development, testing, and automation
Keywords
Readme
Postman CLI
API engineering for your agents. Go faster from development to production with higher accuracy and fewer tokens.
Requests, collections, specs, functional and performance tests, mocks, simulations and monitors for coding agents, terminals and CI pipelines.
Docs · Coding agent plugins · Command reference · Release notes
Install
npm install -g postman-cliWithout Node.js:
# macOS, Linux, WSL
curl -o- "https://dl-cli.pstmn.io/install/unix.sh" | sh
# Windows (PowerShell)
powershell -NoP -NonI -c `
"irm https://dl-cli.pstmn.io/install/win64.ps1 | iex"The Postman desktop app includes the CLI. Update with postman update. See the installation guide for other options.
Quick start
# Set up the repo, install agent skills, link a workspace
postman init
# Send a request
postman request GET https://api.example.com/health
# Run a collection and its tests
postman collection run postman/collections/ordersWhat postman init sets up
postman init turns a repo into a Postman project that agents and teammates can build on.
- API work as files in git. Collections, specs, environments, mocks and simulations live under
postman/, next to your code (Native Git). An existing OpenAPI or AsyncAPI spec is adopted as it is. - Agent skills in the repo. Skills under
postman/skills/and a pointer inAGENTS.mdshow coding agents how to build and test the API with the CLI. - A linked Postman workspace.
.postman/resources.yamlconnects the repo to a workspace, so collections, monitors and mocks have a shared home from the first command. - Context that carries over. Run results, pushes with their messages, and who or which agent did what are saved to the workspace. The next session, agent or teammate picks up from there with
postman workspace context, and the same context keeps your API Catalog and Context Graph current. - The same setup in CI. Builds reuse the workspace recorded in
.postman/resources.yaml.
Run postman init --dry-run to see what it will do first. See postman init.
Agent skills
postman init installs Postman's agent skills in postman/skills/ and adds a pointer to them in AGENTS.md. postman update updates the CLI and the repo's skills. postman status shows the CLI version, skills, account and plugin state.
| Skill | What you get |
|---|---|
| api-discovery | Reuse the APIs your organization already has, and see what depends on one before you change it |
| api-testing | A repeatable test for every change, so regressions surface in review |
| api-mocking | Build against agreed behaviour before the real API or its dependencies exist |
| api-simulation | Test against a realistic environment, including the failures real services won't produce on demand |
| api-monitoring | The same tests that passed in development, running against production |
| ci-integration | Merges that fail on a broken test, contract or governance rule |
| performance-testing | Releases gated on latency and error-rate thresholds |
Usage
The examples below cover common tasks. For the full reference, run man postman, postman --help, or postman <command> --help.
Requests
Send requests while you develop, with assertions on each response, secret variables kept out of the command line, and the request's context retained for later testing and verification.
postman request POST http://localhost:3000/auth/token \
--body @creds.json --response-only
postman request PATCH http://localhost:3000/orders/42 \
--auth-bearer-token "$TOKEN" \
--body '{"status":"shipped"}' \
--script-post-request "pm.test('ok', () => pm.response.to.be.ok)"Exits 0 on a 2xx or 3xx response with all tests passing. Otherwise exits with the number of failed tests. See postman request.
Collections and specs
Turn specs and ad hoc requests into collections, lint specs against your governance rules, and run collections as repeatable test suites locally or in CI with the Collection Runner and Spec Hub.
postman spec lint ./openapi.yaml
postman spec generate collection ./openapi.yaml \
--name "Orders API"
postman collection import ./login.curl
postman collection run postman/collections/orders \
-e postman/environments/dev.environment.yamlMocks
Reproduce how an API behaves, not just what it returns. A Code Mock keeps state across requests, validates incoming calls and runs named scenarios, so it becomes a dependency you control without running another service.
# From an OpenAPI spec or collection; --mode ai adds realistic data
postman mock generate specs/payments.yaml --stateful
postman mock run postman/mocks/payments --port 4010
postman collection run postman/collections/checkout \
--use-mock "{{paymentsUrl}} mock:postman/mocks/payments"A mock is a Node.js request handler in postman/mocks/<name>/, versioned and reviewed with your code. Use pm.state to keep state between requests:
const http = require("http");
http.createServer(async (req, res) => {
const key = req.headers["idempotency-key"];
const seen = await pm.state.get(key);
if (seen) return res.end(JSON.stringify(seen));
if (req.headers["x-test"] === "429") {
res.writeHead(429); return res.end();
}
const charge = { id: "ch_" + Date.now(), status: "succeeded" };
await pm.state.set(key, charge);
res.writeHead(201); res.end(JSON.stringify(charge));
});--use-mock points every request to {{paymentsUrl}} at the local mock for the length of the run. pm.state persists across requests and runs until pm.state.clear(). postman mock run --output ndjson streams one JSON event per request for CI.
Named scenarios in config.yaml add delays, failures, alternate responses and rate limits. Select one per request with the x-mock-scenario header. Add pm.test inside a mock to check that callers stay within the contract. Deploy a mock with postman mock deploy to share it as a mock server with a durable URL, isolated sessions and request logs (postman mock log). See mocks.
Simulations
Bring up the whole dependency chain your service calls in seconds, from files in your repo. Mix simulated and real services, switch scenarios as you change code, and let agents develop against it faster than real time.
postman simulation create -n "Checkout" \
--mock postman/mocks/payments \
--mock postman/mocks/orders \
-o checkout.sim.yaml
# Every mock behind one local port
postman simulation run checkout.sim.yaml
# Reach mocks by hostname, with no code changes
postman simulation run checkout.sim.yaml --proxy \
--scenario timeout --lift "npm test"A simulation is a .sim.yaml file that combines mocks and their routing. With --proxy, requests to each mock's origin hostname, such as api.stripe.com, reach the mock, and all other traffic goes to its real destination, so you only simulate what you choose. --lift starts your command with the proxy already configured. Multiple agents can run their own simulations at the same time without interfering with each other.
A context file beside each simulation records the assumptions your code relies on, what was observed and where it came from, including what has and hasn't been verified. The next run, agent or teammate starts from what is already established instead of rediscovering it. Simulations catch problems earlier; they don't replace a final check against the real services.
Add --deploy to postman simulation create to share the whole environment as one mock server with the same routing. See Postman Simulator.
Performance tests
Find out how the API and its business logic hold up under load before you ship, and fail the release when they don't meet your thresholds.
postman performance run postman/collections/checkout \
--peak-vu 200 --duration 5 --load-profile fixed \
--pass-if "less_than(p95, 300)" \
--pass-if "less_than(error_rate, 1)" \
--pass-if "less_than(failure_rate, 1)" \
--output ndjson--duration is in minutes, and --load-profile takes fixed, ramp-up, spike or peak. A failed --pass-if exits 1, which fails the CI job. Thresholds can use avg, p90, p95, p99, error_rate, failure_rate and rps. Load runs from the local machine by default. Use --runner postman-cloud to generate load from Postman's cloud runners.
The pm.test() assertions in your collection run on every iteration under load. failure_rate is the percentage of request executions with a failing test, so an agent can tell whether the logic still holds at 200 users without working through traces and metrics. In Postman, the run's Tests tab shows each assertion against the number of virtual users, so you can see where it starts to fail. See Performance Testing.
Datasets
Bring test data from the files and databases you already use, query it with SQL, and reuse it on every run. Agents get the same data for repeated testing, and can add synthetic data as CSV or JSON sources when real data isn't available.
postman dataset create users.dataset.yaml --name "Users"
postman dataset source add -d users.dataset.yaml \
-n users --file users.csv
postman dataset query users.dataset.yaml \
-q "SELECT * FROM users LIMIT 5"
postman dataset view create -d users.dataset.yaml -n active \
-q "SELECT * FROM users WHERE active = 1"
postman collection run postman/collections/orders \
--iteration-data-dataset users.dataset.yaml \
--iteration-data-view activeSources can be CSV, JSON and spreadsheet files, or MySQL, PostgreSQL, SQL Server and other JDBC databases, with credentials taken from Shared Vault. The same dataset feeds collection runs, performance tests, monitors and mocks. See Datasets.
Monitors
Keep running the tests that passed in development against production, on a schedule, and hear about failures first with Monitors.
postman monitor create --collection <collection-id> \
--schedule "*/5 * * * *" \
--notify-email [email protected]
postman monitor run <monitor-id>
postman monitor jobs list <monitor-id> --result failureSend alerts to email or any of Postman's monitor integrations. Run monitors inside your own network with postman runner start (private runners).
Secrets
Use API keys and tokens in requests and runs without putting them in your code, your shell history or your agent's context.
postman secret create PAYMENTS_API_KEY
postman environment var set api_key --secret-id <id> \
-e postman/environments/staging.environment.yamlSecret values are entered in a one-time browser form and stored in your team's Shared Vault. The CLI never prints them, and coding agents never see them.
Workspace context
Share what was built and tested with the next person or agent in a Postman workspace, so they start from the work already done.
postman workspace push --yes -m "Add refunds endpoint and tests"
# What the workspace holds and how it relates
postman workspace context
# Recent push messages, one line each
postman workspace activity --type workspacePush --limit 5 --brief
postman workspace pullUse -m to record what changed. workspace context lists the workspace's collections, environments, monitors, mocks, specs and flows, and which monitors run which collections. workspace activity shows each change with its author, and changes made by agents appear as Name (Agent), for example Ada Lovelace (Claude Code). Monitor runs and runs of linked collections are recorded in the workspace. Collection runs from CI include the commit and pipeline.
Context Graph
Find out what depends on an API, and what a change will break, before you make it.
postman context-graph ask \
"What depends on the billing service's invoice response?" \
--wait --jsonContext Graph maps your organization's APIs, deployments, database schemas, external services and teams into a single dependency graph, built from Git-connected Postman workspaces plus the sources you connect, such as GitHub repositories and New Relic. It answers how your services relate to each other and gives agents grounded, queryable context about your architecture.
Answers draw on the sources your team connects in Postman under Home > Agent Context. Use code search for anything outside them. postman dependency add pulls in collections and specs published by other teams. postman describe returns the details an agent needs to write code against an API. Learn more
Public APIs using Orbit
Integrate third-party APIs with instructions drawn from their live schemas, from auth to known gotchas.
Orbit finds public API endpoints for a task and returns instructions to call them. The api-discovery skill uses it automatically.
claude mcp add --transport http orbit \
https://mcp.buildwithorbit.ai/mcpAccounts
All capabilities are available without signing in. Signing in associates your work with a Postman account from then on: postman signup creates a new account, and postman login connects an existing one.
postman whoami
postman signup
postman login
postman login --with-api-key <api-key> # or set POSTMAN_API_KEYThe CLI supports Postman's EU region for teams whose data is hosted in the EU. Sign in with postman login --region eu (or postman login --with-api-key <api-key> --region eu), and the CLI works against the EU region from then on. Private runners take the same --region eu option. See EU data residency.
Postman plugin for coding agents
Install the Postman plugin to make the skills available in every repo you open in your coding agent. The plugin runs its commands through this CLI. postman init adds the skills to one repo, so everyone who clones it gets them.
# Every agent on this machine
npx @postman/postman-plugin
# Claude Code
claude plugin marketplace add anthropics/claude-plugins-official
claude plugin install postman@claude-plugins-official
# Codex
codex plugin marketplace add postmanlabs/postman-plugin
codex plugin add postman@postman
# Cursor
/add-plugin postmanAlso available for OpenCode, GitHub Copilot CLI, Antigravity, Factory, Kimi Code and Pi. See Install the Postman plugin.
CI/CD
- Authenticate with
POSTMAN_API_KEYorpostman login --with-api-key. - Commands exit non-zero on failure.
--jsonfor machine-readable output,--output ndjsonfor streaming,--yesto skip prompts.postman workspace diff --exit-codefails when local files and the cloud workspace differ.- In CI,
postman inituses the workspace recorded in.postman/resources.yaml. - GitHub Actions: Postman CLI GitHub Action.
Migrating from Newman
postman collection run accepts Newman's main options and also runs v3 YAML collections from Native Git. Convert a v2.1 collection with postman collection migrate. See Migrate from Newman.
Platform support
- macOS (Intel and Apple Silicon)
- Linux (x64 and ARM64). Alpine is not supported.
- Windows (x64)
If you see Binary not found, make sure optional dependencies are installed (no --omit=optional, no optional=false in .npmrc) and your registry can reach @postman/* packages. If you installed with both npm and the install script, run which postman to see which one is on your PATH.
Documentation
Support
postman feedback "<message>"- GitHub Issues
