Mock Alpha

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

TypeDescription
DefaultFallback — served when no other scenario matches
NamedA named alternative with a specific response
ConditionalA 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-404
GET /api/mock/users/123?_scenario=error-404

Creating scenarios

  1. Open an endpoint from the Endpoints page
  2. Click + Add Scenario
  3. Set a name (e.g., success, error-500, empty-list)
  4. Edit the response body, status code, and response headers
  5. 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

On this page