Simulate your API in Postman with a mock server

View as Markdown

Use a mock server to simulate a server for your API requests without having to configure one. Postman supports two types of mock servers:

  • Classic mock servers use saved examples from an HTTP collection to return responses. Use this type of mock server when you want to simulate API behavior from requests and examples in a collection.
  • Code mock servers use JavaScript request handlers and response logic to return dynamic responses. Use this type of mock server when you need custom behavior, stateful responses, or more control over how requests are handled.

Get started with mock servers in Postman

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

For more advanced API simulations, use a code mock server.

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.

Classic mock servers 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.