For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Postman
PricingEnterprise
Contact SalesSign InSign Up for Free
HomeDocs
HomeDocs
      • Overview
      • Schemas
        • Overview
        • Install
          • Overview
          • Basic CLI commands
          • Authentication commands
          • Workspace commands
          • Collection commands
          • Request commands
          • Monitoring and performance commands
          • Application commands
          • Flows commands
          • API governance commands
          • Mock server commands
          • Simulator commands
          • Publish API versions commands
        • Built-in reporters
        • Postman CLI GitHub Action
Postman API Platform

Product

  • Postman Overview
  • Enterprise
  • Spec Hub
  • Flows
  • Agent Mode
  • API Catalog
  • Fern
  • Postman CLI
  • Integrations
  • Workspaces
  • Plans and pricing

API Network

  • App Security
  • Artificial Intelligence
  • Communication
  • Data Analytics
  • Database
  • Developer Productivity
  • DevOps
  • Ecommerce
  • eSignature
  • Financial Services
  • Payments
  • Travel

Resources

  • Postman Docs
  • Academy
  • Community
  • Templates
  • Intergalactic
  • Videos
  • MCP Servers

Legal and Security

  • Legal Terms Hub
  • Terms of Service
  • Postman Product Terms
  • Security
  • Website Terms of Use

Company

  • About
  • Careers and culture
  • Contact us
  • Partner program
  • Customer stories
  • Student programs
  • Press and media
Twitter iconLinkedIn iconGithub iconYouTube iconInstagram iconDiscord icon
Download Postman
Privacy Policy

© 2026 Postman, Inc.

On this page
  • postman mock run
Postman CollectionsPostman CLICLI commands

Mock server commands

||View as Markdown|
Was this page helpful?
Previous

API governance commands

Next

Simulator commands

Built with

This topic covers mock server commands for the Postman CLI.

postman mock run

You can use the postman mock run command to start a local mock server from a configuration file.

To run a collection against a mock server, use the --mock option with the postman collection run command.

This command starts a local mock server from a configuration file in JSON format. With the configuration file, you can configure details like the mock server’s port number, name, script, and more. The mock server runs on the specified port until you stop it. Make sure you also have a JavaScript file with an HTTP server that sets the request and example response for simulating real API behavior.

Add the command to your CI/CD script to start a mock server as a dependency for your application or test suite. Once running, your service or external tests can send requests to it as if it were a real API. This enables you to simulate API behavior for testing and development.

Learn more at Simulate your API using a Git-backed mock server.

Usage

$postman mock run <config-file>
<config-file>

The path to the mock server configuration file in JSON format.

Options

-e, --environment <path>

Specifies the path to an environment file (JSON or YAML) loaded into pm.environment for the mock server’s scripts.

-g, --globals <path>

Specifies the path to a globals file (JSON or YAML) loaded into pm.globals for the mock server’s scripts.

Example

$postman mock run mock-config.json
$
$postman mock run mock-config.json --environment ./postman/environments/dev.yaml

Learn more at Mock APIs.