Postman CLI performance commands (postman performance)
Postman CLI performance commands (postman performance)
This topic covers the postman performance commands for the Postman CLI.
postman performance run
The postman performance run command runs a performance test for a specified collection and makes the results available in Postman. By default, the test’s load originates from the machine that invokes the command. Use the --runner option to originate load from Postman’s managed cloud infrastructure instead. Learn more at Configure and validate performance tests using the Postman CLI.
The command runs the performance test against the specified collection, returning the performance test results in Postman. Specify the collection with its ID, or with the path to a local collection.
When you pass a local collection path, the command runs the test as follows:
- The command runs the current local files, including changes you haven’t pushed, and shows the results in your terminal. A link to a cloud collection in
.postman/resources.yamldoesn’t change this or require you to sign in. - The results aren’t recorded to the Postman Cloud.
To run the pushed copy of a linked collection and record the run, pass its collection ID, or use --runner postman-cloud.
Call other requests from scripts in a local run
With the default local runner, a script can call the pm.execution.runRequest method with a request ID. The command loads the requests that your scripts name as string literals or list in script.requests. IDs that your scripts build while they run aren’t supported.
If a request can’t load, the command prints a warning that names the request IDs, and the run continues. Calls to a request that didn’t load fail during the run.
Use cloud files in a local run
If the collection uses files stored in the Postman Cloud, a local run downloads them to a temporary folder before the run starts. The run’s timer starts after the downloads finish. If a file can’t be downloaded, the command stops with an error that names the file ID before the run starts. A download can fail if you aren’t signed in, or if Postman doesn’t respond within 60 seconds.
Sign in to Postman with the postman login command when part of the run reaches Postman Cloud: a cloud collection, an environment or globals, setup or teardown collections, a dataset, or a mock server. If you aren’t signed in for one of these, the command prints a sign-in notice to stderr.
Usage
The unique identifier of the collection to run performance tests against, or the path to a local collection.
Options
Specifies the path to a data file with custom values to use for each virtual user. The file must be in CSV or JSON format. Each virtual user uses a random row each time it runs the requests. Can’t be used with --dataset-id or with --runner postman-cloud. To provide data for a cloud run, or to control how rows map to virtual users, use a dataset instead. Learn more about using a data file to simulate virtual users.
Specifies the ID of a dataset to use as iteration data for each virtual user. Must be used with --dataset-view-id. Can’t be used with --data-file. Learn more about using a dataset to simulate virtual users.
Specifies the ID of the dataset view to use. The view controls which rows are available to virtual users during the test. Must be used with --dataset-id.
Controls how rows are assigned to virtual users. Accepts round-robin, fixed, or random. Learn more about strategies.
Loads a local .dataset.yaml file, or a directory of them, for the local mocks that --use-mock starts to read with pm.datasets(<id>). Pass --dataset more than once to load multiple datasets. Unrelated to --dataset-id, which selects a Postman Dataset as iteration data rather than feeding a mock. Supported only with --runner local, the default.
Replaces all symbols in the output with their plain text equivalents.
The duration of the performance test, as a whole number of minutes. A value with a unit, such as 30s or 1h, returns an error, so convert it to minutes first.
Specifies an environment by its ID. Variables in the collection are resolved from the environment.
Specifies globals by its ID. Variables in the collection are resolved from globals.
Turns off SSL certificate verification for the target. Supported only with --runner local, the default.
The load profile type to use for the performance test. Accepts fixed, ramp-up, spike, or peak. Each profile breaks the test duration into phases. Use --load-segments to set how long each phase lasts, or --base-vu to set the floor virtual user count. With --base-vu, omitted phases and the floor fall back to the following defaults:
- With
fixed, virtual users hold at--peak-vufor the whole duration.--base-vuand--load-segmentsdon’t apply. - With
ramp-up, virtual users hold at the floor (25% of peak by default) for the first 25% of the duration, ramp up to peak over the next 25%, then hold at peak for the rest. - With
spike, virtual users hold at the floor (10% of peak by default) for the first 40% of the duration, ramp up to peak over the next 10%, ramp back down to the floor over the following 10%, then hold at the floor for the rest. This profile doesn’t hold at the peak itself, so usepeakto hold there. - With
peak, virtual users hold at the floor (20% of peak by default) for the first 20% of the duration, ramp up to peak over the next 20%, hold at peak for the following 20%, ramp back down to the floor over the next 20%, then hold at the floor for the rest.
The peak (maximum) virtual users that simulate traffic to your API. Must be a whole number. Same option as --vu-count. Use one or the other, but not both. Cloud runs require a minimum of 10 virtual users.
The base (floor) virtual users the run starts from. Not supported with --load-profile fixed, which runs flat at --peak-vu. Must be at least 1 and a whole number less than --peak-vu. Defaults to a percentage of --peak-vu that depends on --load-profile.
The duration of each phase of the load profile, as a comma-separated list in the order the phases run. Leave a position empty to keep its default, so you can set only the phases you care about. Each duration is a whole number of minutes, or a number with a unit, such as 30s, 1m30s, or 10m.
ramp-uptakes 2 segments: warm-up, ramp-up.spiketakes 3 segments: warm-up, ramp-up, ramp-down.peaktakes 4 segments: warm-up, ramp-up, hold, ramp-down.fixedtakes no segments.
The segments you set must fit inside --duration, or the run is refused before it starts. Only a segment left at its default is ever shrunk to make room. A segment you gave an explicit duration to never shrinks, so it has to fit inside --duration on its own.
For example, on peak, --load-segments ,,5m, sets only the hold phase to 5 minutes and leaves the rest at their defaults. On spike, --load-segments ,20s,10s sets the ramp-up and ramp-down phases, leaving warm-up at its default.
The format for the live results the command streams as the test runs. With auto, the default, the command shows an interactive dashboard on a terminal. With ndjson, it streams the results as newline-delimited JSON. This is useful when you pipe or redirect the output, or run the command from an agent or CI, where the dashboard can’t render. The final summary event includes a recorded field. For a local run that isn’t recorded, recorded is false and runNumber is null.
Specifies a condition that determines whether the performance test passes or fails. The condition must be in the function(metric, value) format. When the condition is met, the command exits with code 0. When it isn’t met, the command exits with code 1, which fails the job that started the run. This applies to both local and cloud runs.
Repeatable. Pass --pass-if more than once to require every condition to pass. The test fails if any one condition doesn’t pass.
Functions:
less_than(metric, value)— The test passes if the metric is less than the value.less_than_eq(metric, value)— The test passes if the metric is less than or equal to the value.greater_than(metric, value)— The test passes if the metric is greater than the value.greater_than_eq(metric, value)— The test passes if the metric is greater than or equal to the value.
Metrics:
avg— The response time of all requests averaged together, in milliseconds.p90— The 90th percentile of response times, in milliseconds.p95— The 95th percentile of response times, in milliseconds.p99— The 99th percentile of response times, in milliseconds.error_rate— The percentage of requests with an error. Errors indicate runtime issues such as timeouts, connection or TLS failures, or uncaught exceptions in user scripts.rps— The number of requests sent per second.
Examples:
--pass-if "less_than(p95, 500)"— The test passes if the 95th percentile of response times is less than 500 milliseconds.--pass-if "less_than_eq(error_rate, 5)"— The test passes if the percentage of requests with an error is less than or equal to 5%.--pass-if "less_than(p95, 500)" --pass-if "less_than(error_rate, 5)"— The test passes only if both conditions hold.
Specifies the API key used to load resources from the Postman API. Only supported in the US region. To authenticate in the EU region, use postman login --region.
Specifies where the performance test’s load originates. Specify one runner for each run. Repeating the option returns an error.
local— Runs on the machine that invokes the command.postman-cloud— Runs on Postman’s managed cloud infrastructure. Requires cloud performance tests to be available on your plan.postman-cloud-static-ip— Runs on a static-IP cluster in the region of your logged-in account (US by default, or EU for EU Data Residency plans), so you can allowlist the load’s source IPs in your firewall. Requires static IPs to be available on your plan.
The two cloud runners accept a collection ID, or the path to a local collection that’s linked to a cloud collection in .postman/resources.yaml. Any other local path returns an error. To run another local collection, use --runner local.
Specifies the ID of a collection to run once before the performance test starts. Use a setup collection to prepare something the test needs, such as creating an account or requesting an access token. Only a collection ID is supported. Works with every runner, including the default --runner local. Learn more about running a performance test with setup and teardown collections.
Specifies the path to a client certificate (PEM) to present to mutual TLS (mTLS) targets. Supported only with --runner local, the default.
Specifies the path to a client certificates configuration file (JSON) that maps certificates to hosts, for per-URL client certificates. Supported only with --runner local, the default.
Specifies the path to the client certificate’s private key. Supported only with --runner local, the default.
Specifies the passphrase for a protected client certificate key. Supported only with --runner local, the default.
Specifies the path to additional trusted CA certificates (PEM) for the target, such as an internal certificate authority. Supported only with --runner local, the default.
Specifies the ID of a collection to run once after the performance test ends, on every outcome, including when the run completes, is canceled, fails, or times out. Use a teardown collection to clean up afterward, such as deleting data the test created. Works with every runner, including the default --runner local.
Redirects requests to a mock while the performance test runs, using the same mapping format as postman collection run --use-mock. Pass --use-mock more than once to redirect multiple mappings. This option applies only to local runs. With --runner postman-cloud, the Postman CLI ignores it and prints a warning.
The ID of the workspace that owns the Postman Shared Vault for the collection’s v12 secret variables. Required for cloud runs that resolve those secrets. Omit it if the run uses no vault secrets. Local runs ignore this option and print a warning.
Previous name for --peak-vu. Use one or the other, but not both. Cloud runs require a minimum of 10 virtual users.
Examples
postman performance get
Gets one performance run by its run ID.
Usage
The ID of the performance run to get.
Options
The output format for the results.
Prints the result as JSON for machine-readable output. An alias for --output json.
The time to wait for the service before failing, in milliseconds.
Examples
postman performance list
Lists a collection’s past performance test runs, newest first, so you can review historical results and track trends. Specify the collection with its ID.
Usage
Options
The ID of the collection whose performance runs to list.
A pagination cursor from a previous page’s response. The command returns the newest 25 runs per page. When more are available, it prints a cursor to pass here for the next page.
The output format for the results.
Prints the results as JSON for machine-readable output. An alias for --output json.
The time to wait for the service before failing, in milliseconds.