Collection commands
This topic covers collection-related commands for the Postman CLI.
You can run your collections with HTTP requests using the postman collection run command. With a paid plan, you can also run collections with gRPC and GraphQL requests.
You can also use the postman collection migrate command to migrate collections from the v2.1 JSON format to the v3 YAML format.
postman collection run
This command runs a collection and displays run results in the terminal. If you’re signed in to Postman, the command sends the run results to the Postman cloud. Learn how to sign in to Postman with the postman login command.
Specify the collection with its file path if you’re running it locally. If you’re signed in to Postman, specify the collection with its ID to send the results to the Postman cloud.
You can find the collection ID in Postman. Click the Items tab, click Collections in the sidebar, and select a collection. Then click the
Info tab in the right sidebar to view or copy the collection ID.
Usage
One of the following:
- A collection file path if running locally.
- A collection ID (UUID format) if signed in to Postman.
Options
Specifies whether to stop a collection run on encountering the first error. --bail can optionally accept two modifiers: --folder and --failure. --folder skips the entire collection run if there are any errors. If a test fails, --failure stops the collection run after completing the current script.
Controls colors in the CLI output. Accepts on, off, and auto. With auto, the Postman CLI attempts to automatically turn color on or off based on the color support in the terminal.
Specifies the file path for a JSON cookie jar. This uses the tough-cookie library to deserialize the file.
Specifies a delay (in milliseconds) between requests.
Replaces all symbols in the output with their plain text equivalents.
Specifies an environment file path or UID.
Specifies environment variables in a key=value format. Multiple CLI environment variables can be added by using --env-var multiple times, for example: --env-var "this=that" --env-var "alpha=beta".
Specifies the path where the Postman CLI will output the final cookie jar file after completing a run. This uses the tough-cookie library to serialize the file.
Specifies global variables in a key=value format. Multiple CLI global variables can be added by using --global-var multiple times, for example: --global-var "this=that" --global-var "alpha=beta".
Specifies a path to a file containing global variables. Global variables are similar to environment variables but have lower precedence and can be overridden by environment variables having the same name.
(This option is only supported in Postman v11 and earlier.) Specifies an integration ID when using an integration with CI/CD. This sends the Postman CLI results to the correct integration in Postman.
Specifies the number of times the collection will run when used in conjunction with the iteration data file.
Specifies the local file path to a data file (JSON or CSV) to use for each iteration.
Runs only the specified folder UID or request UID from the collection. Multiple items can be run in order by specifying -i multiple times, for example: postman collection run collectionUID -i folder1UID -i folder2UID.
Runs only the specified folder name or request name from the collection. If there are duplicate names, the Postman CLI runs the folder or request that appears first.
Prevents the Postman CLI from automatically following 3XX redirect responses.
Turns off SSL verification checks and enables self-signed SSL certificates.
Specifies the path to a mock server configuration file in JSON format. This starts a mock server using the specified configuration, runs the collection against the mock server, and then stops the mock server. Learn how to create a mock server in your Git repository.
Prevents reading of files situated outside of the working directory.
Turns off terminal output.
Specifies the path to a client certificates configuration (JSON).
Specifies the path to a client certificate (PEM).
Specifies the path to a client certificate private key.
Specifies the client certificate passphrase (for a protected key).
Specifies more trusted CA certificates (PEM).
Specifies whether to override the default exit code for the current run.
Specifies the time (in milliseconds) to wait for the entire collection run to complete.
Specifies a time (in milliseconds) to wait for requests to return a response.
Specifies the time (in milliseconds) to wait for scripts to complete.
Shows detailed information for the collection run and each request sent.
Sets the path of the working directory to use while reading files with relative paths. This defaults to the current directory.
Generates a local report for the collection run in the specified format: cli, json, junit, and html. If the --reporters option isn’t specified, the cli report is output by default. Only the cli report output is supported for collections with HTTP, gRPC, and GraphQL requests. To learn more, go to Generate collection run reports using the Postman CLI.
Examples
Learn more at Run a collection using the Postman CLI and Use the Postman CLI with GitHub Actions.
postman collection migrate
Use the postman collection migrate command to migrate your existing v2.1 collection to the new v3 collection format.
Usage
Path to the existing v2.1 collection file to migrate.
Options
Specifies the directory to migrate your new collection to. If you don’t specify a directory, the Postman CLI saves the new collection in the current directory.