documentation/features/mock.mdx
Hoppscotch API Mocking lets you stand up mock servers that return predictable responses to HTTP requests. It's ideal for prototyping, front‑end development, contract-first API design, demos, and testing failure/latency scenarios, now built right into Hoppscotch.
You can create a mock server from scratch or from an existing Collection.
New mock server
From a Collection
Once created, you'll get a mock server URL you can call from your app or your Hoppscotch requests.
<Tip>Keep the mock server URL in an Environment variable, for example {{MOCK_BASE_URL}}, so you can swap between mock and real servers easily.</Tip>
A mock server is made of one or more routes. Each route matches an incoming request and returns a configured response.
Route fields:
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONSRequest
GET /users/42
Response
{
"id": 42,
"name": "Jane Doe",
"role": "admin"
}
Use Hoppscotch variables to make responses dynamic and realistic.
{{timestamp}}{{uuid}}{{ENV_NAME}}Example dynamic body:
{
"requestId": "{{uuid}}",
"generatedAt": "{{timestamp}}",
"region": "{{REGION}}"
}
You can also reference variables in headers, for example X-Request-ID: {{uuid}}.
In Hoppscotch, you can save responses as examples to quickly populate mock routes with realistic data. Examples capture both the request configuration and its actual response, making it easy to convert real API behavior into mock endpoints.
To save a response as an example:
Using examples in mock servers:
Example workflow:
<Tip>Use examples to quickly bootstrap realistic mock data from your actual API, then refine them to test edge cases and failure scenarios.</Tip>
Control the realism of your mocks by tuning:
Content-Type, Cache-Control, custom headers<Tip>Simulate network timeouts by setting a delay higher than your client's timeout to test retry logic.</Tip>
{{MOCK_BASE_URL}}Example request target:
{{MOCK_BASE_URL}}/orders?limit=10
Mocks live in your workspace, so teammates can:
{{MOCK_BASE_URL}}, {{REGION}}) in EnvironmentsAccess-Control-Allow-Origin: * (or your origin) to the response headersMocks return predefined responses based on your rules. They don't execute business logic or touch data stores.
Yes. You can bootstrap routes from saved requests or examples in a Collection and refine them.
Yes. Use Hoppscotch variables (UUID, timestamp, and Environment values) directly in response bodies and headers.
Yes. See Self‑host for details on deploying Hoppscotch in your own infrastructure.