Skip to navigation

Postman CLI quickstart

View as Markdown

In this tutorial, you use the Postman CLI to set up a project, create a collection with one request and one test, run it, and push it to a Postman workspace. Every step is a command you can run yourself or have a coding agent run for you.

Prerequisites

Before you start, do the following:

  1. Install the Postman CLI.

  2. Sign in to Postman:

    postman login

    The command opens your browser to sign in. For more on signing in, including API keys and temporary sessions, see Postman CLI authentication and configuration.

  3. Check that you’re signed in:

    postman whoami

Set up a project

Create a folder for the project, turn it into a Git repository, and run postman init:

mkdir postman-quickstart
cd postman-quickstart
git init
postman init

The command adds a .postman/ folder with the project configuration, an AGENTS.md file, and Postman’s agent skills under postman/skills/. Because you’re signed in, it also offers to create a Postman workspace and connect your project to it. Answer yes, and choose personal visibility so the workspace is private to you.

To skip the prompts, for example in a script or from an agent, run postman init --yes --visibility personal.

Create a collection

Create a local collection named Quickstart with postman collection new:

postman collection new "Quickstart"

The command prints the location of the new collection:

Created postman/collections/Quickstart

Add a request and a test

Add a request to the collection with postman collection request add:

postman collection request add "Get echo" --collection Quickstart

The new request is empty. Set its method and URL, and add a test script that checks for a 200 status, with postman collection request update:

postman collection request update "Get echo" --collection Quickstart \
--method GET \
--url https://postman-echo.com/get \
--scripts 'test:pm.test("Status is 200", function () { pm.response.to.have.status(200); });'

Run the collection

Run the collection with postman collection run:

postman collection run postman/collections/Quickstart

The command sends the request, runs the test, and prints a run report. The start of the report looks like this:

Quickstart
Root Get echo
GET https://postman-echo.com/get [200 OK, 1.21 KB, 175 ms]
Pass Status is 200

A summary table follows, with the number of requests, test scripts, and assertions that ran and failed. The command exits with code 0 when everything passes and a non-zero code when a request or test fails, so a script or pipeline can act on the result.

Push the collection to your workspace

Send the collection to the workspace that postman init connected to your project, with postman workspace push:

postman workspace push

The Quickstart collection now appears in your workspace in Postman.

Run it from an agent or CI

The same commands work without a person at the keyboard:

  • Pass --yes to postman init and postman workspace push so they don’t stop to ask questions.
  • Read the exit code of postman collection run to decide whether a build or an agent task passed.
  • Add --output <folder> to postman collection run to write a YAML run report that a script or an agent can read.

To learn more about non-interactive use, output formats, and exit codes, see Use the Postman CLI with AI agents and CI/CD.