Simulate your API in Postman with a mock server

View as Markdown

Postman lets you simulate your API without a real backend using mocks and mock servers:

  • Mocks use JavaScript request handlers and response logic to return dynamic responses. Use a mock when you need custom behavior, stateful responses, or more control over how requests are handled. You can start a mock locally and send requests to it, or deploy it as a mock server.
  • Mock servers are deployed to the Postman cloud and are always available to handle requests. You can create a mock server from a mock or from an existing collection.

Get started with mock servers in Postman

To create a mock, see Build API mocks with JavaScript.

To create a mock server, you can create one from a mock or an existing collection, or build one from your request history.

After setting up your mock server, you can make calls to it from Postman or from a client application. The mock server simulates your API’s behavior, so you can test your API or develop new functionality before your API is production ready.

To test how your service responds when multiple dependencies fail at the same time, you can create and run simulations with Postman Simulator.

Mock servers created from a collection can generate dynamic responses using variables and templates.

Level up with step-by-step guides

If you need more help setting up a mock server, follow the step-by-step guide to mock your API using saved response examples. You’ll learn how to add requests and examples to your collection, then use the collection to configure and use a mock server.

If you want to automate your mock servers, follow the step-by-step guide to set up mock servers using the Postman API. You’ll learn how to use the Postman API to mock a collection and get the mock server URL.

Learn how Postman mock servers work

When you send a request to a mock server, Postman uses an algorithm to choose the saved example that best matches the request. The mock server then returns a response using the data in the saved example.

Dive deeper into the matching algorithm and learn how to create examples so you always get the responses you expect from the mock server.