Mock Scenarios
Define and switch between response scenarios for each endpoint
Mock Scenarios
Every endpoint in Mock Alpha can have multiple scenarios — different responses it can serve. You pick the active scenario from the dashboard; your app always gets the response you selected.
Scenario types
| Type | Description |
|---|---|
| Default | Fallback — served when no other scenario matches |
| Named | A named alternative with a specific response |
| Conditional | A scenario with match rules — served only when the request matches defined conditions |
Switching scenarios
From the endpoint detail page, select any scenario from the scenario panel on the right. Your selection is saved immediately and persists across restarts.
You can also switch scenarios programmatically:
POST /api/projects/{projectId}/scenarios/{endpointId}/override
Content-Type: application/json
{ "scenarioId": "<scenario-uuid>" }Or per-request using a header or query parameter:
GET /api/mock/users/123
X-Mock-Scenario: error-404GET /api/mock/users/123?_scenario=error-404Creating scenarios
- Open an endpoint from the Endpoints page
- Click + Add Scenario
- Set a name (e.g.,
success,error-500,empty-list) - Edit the response body, status code, and response headers
- Optionally add match rules for conditional routing
Response body editor
The response body is a JSON editor. You can type any valid JSON. You can also use template placeholders to echo request data back in the response:
{
"id": "{{request.path.id}}",
"name": "{{request.body.name}}",
"filter": "{{request.query.filter}}"
}See Response Templates for the full placeholder reference.
Scenario priority
When multiple scenarios have match rules, priority determines evaluation order. Lower numbers are evaluated first. The first scenario whose rules all pass is served.
The default scenario (no match rules) is always the final fallback — it is never part of the priority evaluation.
Status codes and headers
Each scenario can override:
- Status code — default
200 - Response headers — key/value pairs merged with defaults
- Response delay — milliseconds to wait before responding (useful for testing loading states)
Resetting to default
To clear a scenario override and return to the default scenario, click Reset to Default in the scenario panel, or send:
DELETE /api/projects/{projectId}/scenarios/{endpointId}/override