Mock APIs and their dependencies in Postman
With Postman, you can stand in for an API without a real backend, whether it’s your own API before it’s built or an external service your app depends on. Dependencies that are still being built, owned by another team, rate-limited, or costly to call can block your development and testing. A stand-in lets you keep moving and reproduce failures on demand. You, or a coding agent working in your repository, can develop and test against one without sandbox accounts, credentials, or a running service.
With mocks and mock servers, you can:
- Build against your own API before the backend exists.
- Stand in for a third-party or team-owned service that’s unavailable, rate-limited, or costs money to call.
- Test how your service handles latency, errors, and rate limits, without touching the real dependency.
- Give a coding agent a realistic environment to build and test against.
- Run tests in CI with no live backend.
You build these stand-ins as mocks and mock servers:
- A mock is a code-based stand-in you write in JavaScript. Use a mock when you need custom logic, stateful responses, or more control than saved examples give you. Run it locally, or deploy it as a mock server.
- A mock server is an always-available hosted stand-in at a stable URL. Create one from a mock to run your code in the cloud, or from a collection of saved examples for a no-code stand-in.
When your app depends on more than one service, you can group several mocks into a simulation to stand in for the whole set at once. Run your service against all of them, then make them fail together to see how your service responds. To learn more, see Simulate API conditions with Postman Simulator.
Mocks
Create a mock by hand, from a specification or collection, or with Agent Mode. Customize its JavaScript to return dynamic, stateful responses, add scenarios and behaviors to test failures, and run it locally or deploy it as a mock server.
Learn more at Create mocks with JavaScript.
Mock servers
Deploy a mock server so your teammates, tests, and CI pipelines can call a stable URL without a real backend. Create one from a mock, to run your code in the cloud, or from a collection, to return saved examples matched to each request.
Learn more at Create a Postman mock server from a mock or a collection.