Skip to navigation

Postman CLI simulation commands (postman simulation)

Beta
View as Markdown

Postman Simulator is available on Postman Solo, Team, and Enterprise plans. For more information, see the pricing page.

This topic covers simulation commands for the Postman CLI.

A simulation groups several existing mocks as members and serves them behind one address. For each member mock, you select a scenario to simulate real-world conditions like latency, errors, and rate limits. To learn more about the concept, see Simulate API conditions with Postman Simulator.

A simulation lives as a .sim.yaml file in your repository, or as a simulation in a Postman Cloud workspace. postman simulation push uploads a local file to the cloud, and postman simulation deploy turns a cloud simulation into a live mock server with a public address.

To run a collection with a simulation, use the --simulate option with the postman collection run command.

postman simulation create

Scaffolds a .sim.yaml file that groups one or more existing mocks into a simulation. Pass each member mock with --mock, repeating the option to add more than one. A local mock path builds the simulation in your repository. A Postman mock ID creates it directly in a Postman Cloud workspace instead. Use one kind of reference or the other, not both in the same command.

Set a member’s address with <mockIdOrPath>=<routeKey>. If you omit the routeKey, the mock’s own name is used.

To create a simulation in a Postman Cloud workspace, sign in with the postman login command or pass --api-key.

Usage

postman simulation create --mock <mockIdOrPath> [options]

Options

-n, --name <name>

The name for the simulation.

--mock <mockIdOrPath>
Required

A mock to include as a member. Repeatable. Set its address with <mockIdOrPath>=<routeKey>.

--routing <header|path>
Defaults to path

How callers reach each member mock. With path, the first path segment of the request selects the member. With header, callers select a member with the x-mock-slug header.

-o, --output <path>
Defaults to postman/simulations

Where to save the simulation file in your repository, as a file or a folder.

--force

Overwrites the simulation file if it already exists.

-w, --workspace <id>

Creates the simulation in a Postman Cloud workspace, by ID, instead of your repository. Defaults to the workspace linked in .postman/resources.yaml.

--api-key <key>

Your Postman API key, used with --workspace. Defaults to your postman login session.

Examples

# Group two local mocks into a simulation
postman simulation create -n "Checkout" --mock ./postman/mocks/payments --mock ./postman/mocks/orders
# Set a member's address explicitly, and route by header instead of path
postman simulation create -n "Checkout" --mock ./postman/mocks/payments=payments --routing header
# Create the simulation directly in a Postman Cloud workspace
postman simulation create -n "Checkout" -w 12345678-90ab-cdef-1234-567890abcdef --mock <mock-id>=payments

postman simulation list

Lists the simulations in your repository or a Postman Cloud workspace. Listing is local-first: without --workspace, it reads the postman/simulations directory in your repository. Pass --workspace to list a cloud workspace’s simulations instead.

To list a Postman Cloud workspace’s simulations, sign in with the postman login command or pass --api-key.

Usage

postman simulation list [path-or-directory] [options]
[path-or-directory]

A directory to search for local simulations. Defaults to postman/simulations. You can’t combine it with --workspace.

Options

-w, --workspace <id>

Lists the simulations in the specified Postman Cloud workspace, instead of your repository. You can’t combine it with a path.

--api-key <key>

Your Postman API key, used with --workspace. Defaults to your postman login session.

--json

Prints the list as JSON for machine-readable output.

Examples

# Local simulations in your repository
postman simulation list
# Simulations in a specific folder
postman simulation list ./postman/simulations
# Simulations in a Postman Cloud workspace
postman simulation list --workspace 12345678-90ab-cdef-1234-567890abcdef

postman simulation get

Shows one simulation’s details: its member mocks, routing, each member’s scenario, and whether it’s deployed as a live mock server. Specify the simulation by its local .sim.yaml path, or by its ID if it lives in a Postman Cloud workspace.

To read a simulation by its cloud ID, sign in with the postman login command or pass --api-key.

Usage

postman simulation get <simIdOrPath> [options]
<simIdOrPath>
Required

A simulation’s local .sim.yaml path, or its ID if it lives in a Postman Cloud workspace.

Options

--api-key <key>

Your Postman API key, used when you read a simulation by its cloud ID. Defaults to your postman login session.

--json

Prints the result as JSON for machine-readable output.

Examples

# By cloud ID
postman simulation get 12345678-90ab-cdef-1234-567890abcdef
# By local path
postman simulation get ./postman/simulations/checkout.sim.yaml

postman simulation run

Serves a simulation’s member mocks on one local port, routing each request to a member by its routeKey. Pass a local .sim.yaml path, or a Postman Cloud simulation ID to fetch and run the same simulation locally.

With path routing (the default), the first path segment of a request selects the member, so /payments/charges reaches the payments member as /charges. With header routing, callers select a member with the x-mock-slug: <routeKey> header.

Usage

postman simulation run <simIdOrPath> [options]
<simIdOrPath>
Required

A simulation’s local .sim.yaml path, or its ID if it lives in a Postman Cloud workspace.

Options

-e, --environment <path>

Path to a file of environment variables for the member mocks.

-g, --globals <path>

Path to a file of global variables for the member mocks.

-p, --port <port>
Defaults to 3000

Port to serve on. Pass auto to use a free port.

--dataset <pathOrDir>

A dataset file or folder to load for pm.datasets. Repeatable.

-w, --workspace <id>

Workspace to record start history against. Derived automatically from a simulation ID or your linked project, so this is only needed for an unlinked .sim.yaml path.

--simulation <id>

The simulation ID to record start history against, for a .sim.yaml path that isn’t linked to a cloud simulation (a local file has only a name on its own). Not needed when you run by simulation ID, or when the file is linked to a cloud simulation through postman simulation push.

--api-key <key>

Your Postman API key, used when you run by cloud ID. Defaults to your postman login session.

--no-history

Doesn’t record this run in the simulation’s start history.

--output <format>
Defaults to auto

Live output format. auto prints human-readable logs. ndjson prints one JSON event per line, ending with a summary event, for CI or other non-interactive use.

--scenario <name>
Defaults to default

The scenario each member mock serves, sent as both the pm-mock-scenario and x-mock-scenario headers.

Examples

# Serve a local simulation
postman simulation run ./postman/simulations/checkout.sim.yaml
# Fetch a cloud simulation and run it locally
postman simulation run 12345678-90ab-cdef-1234-567890abcdef
# Choose the port, and stream events as NDJSON for CI
postman simulation run ./postman/simulations/checkout.sim.yaml --port 4010 --output ndjson

Proxy mode

Pass --proxy to serve the member mocks behind a local HTTP/HTTPS forward proxy instead of one routed port. A repository under test can then point HTTP_PROXY/HTTPS_PROXY at the proxy and reach each member by hostname, without code changes. Proxy mode requires a simulation.yaml routing configuration file, which is a different file from the .sim.yaml used by the rest of this command.

--proxy

Serves the member mocks behind a local forward proxy instead of one routed port. Records no start history.

--proxy-port <n>
Defaults to 7001

Port for the proxy server. Distinct from --port, which is the routed (non-proxy) run’s own port.

--log-format <format>
Defaults to text

Proxy request log format: text or json.

--log-body

Also logs each response body, truncated. Buffers full responses in memory, so this is meant for temporary debugging rather than regular use.

--doctor

Starts the proxy, probes each available HTTP client (fetch, undici, axios, node-fetch) to confirm it honors HTTP_PROXY/HTTPS_PROXY, then exits.

# Mocks plus an intercepting proxy
postman simulation run ./simulation.yaml --proxy
# Confirm your HTTP client honors the proxy environment variables
postman simulation run ./simulation.yaml --proxy --doctor

postman simulation push

Uploads a local simulation to a Postman Cloud workspace. The first push creates it there, and later pushes update it. Each member mock is pushed too, before the simulation that groups them.

To use this command, sign in with the postman login command or pass --api-key.

Usage

postman simulation push <simPath> [options]
<simPath>
Required

The local .sim.yaml file to upload.

Options

-w, --workspace <id>

The Postman Cloud workspace to upload to, by ID. Defaults to the workspace linked in .postman/resources.yaml.

--api-key <key>

Your Postman API key. Defaults to your postman login session.

Examples

postman simulation push ./postman/simulations/checkout.sim.yaml
postman simulation push ./postman/simulations/checkout.sim.yaml --workspace 12345678-90ab-cdef-1234-567890abcdef

postman simulation deploy

Turns a simulation already in a Postman Cloud workspace into a live mock server that others can call over the internet. To upload a local simulation first, use postman simulation push.

To use this command, sign in with the postman login command or pass --api-key.

Usage

postman simulation deploy <simId> [options]
<simId>
Required

The ID of a simulation in a Postman Cloud workspace. Find it with postman simulation list.

Options

-w, --workspace <id>

The Postman Cloud workspace that will own the server, by ID. Defaults to the workspace linked in .postman/resources.yaml.

-n, --name <name>

A name for the mock server. You’re asked for one if you omit it.

-s, --slug <slug>

A short label used in the server’s web address, such as my-sim. You’re asked for one if you omit it.

--private

Requires a Postman API key to reach the server. Public by default.

-y, --yes

Uses the defaults and skips all questions, including --private, so the server is public.

--api-key <key>

Your Postman API key. Defaults to your postman login session.

Examples

# Asks for a name and a slug
postman simulation deploy 12345678-90ab-cdef-1234-567890abcdef
# Private server, no questions asked
postman simulation deploy 12345678-90ab-cdef-1234-567890abcdef --slug my-sim --private --yes

postman simulation delete

Permanently deletes a simulation, using its local .sim.yaml path or its Postman Cloud ID. This can’t be undone.

Deleting a cloud simulation also takes down its live mock server, if it was deployed. Deleting a local file removes only the .sim.yaml, leaving its member mocks untouched.

To delete a simulation by its cloud ID, sign in with the postman login command or pass --api-key.

Usage

postman simulation delete <simIdOrPath> [options]
<simIdOrPath>
Required

A simulation’s local .sim.yaml path, or its ID if it lives in a Postman Cloud workspace.

Options

-y, --yes

Deletes without asking for confirmation first.

--api-key <key>

Your Postman API key, used when you delete by cloud ID. Defaults to your postman login session.

Examples

# By cloud ID
postman simulation delete 12345678-90ab-cdef-1234-567890abcdef
# By local path, without confirmation
postman simulation delete ./postman/simulations/checkout.sim.yaml --yes