Getting Started

Conditional Matching

A route doesn't have to return the same thing every time. Add match conditions to a route and MockBase only returns that route's response when the incoming request satisfies all of them — otherwise it moves on to the next candidate route for that method and path.

Adding a condition

Each condition has three parts:

  • Source — where to look: query, header, or body.
  • Key — the parameter/header name, or a dot-path into the JSON body (e.g. user.email reaches a nested field). Header lookups are case-insensitive.
  • Operatorequals, not_equals, contains, exists, or regex.

A route can have multiple conditions; all of them must pass for that route to match.

Which route wins

When more than one route could match the same method and path:

  1. Routes are tried in order of priority (higher number first).
  2. Routes with equal priority are tried in the order you added them.
  3. The first route whose conditions all pass — or that has no conditions at all — is the one that responds.

A route with no conditions always passes, so give it the lowest priority among its siblings if you want it to act as a catch-all fallback after more specific, conditioned routes.

No match

If no route for a method and path matches, MockBase returns 404 with {"error": "route_not_found"} — unless Record & Replay is configured for the mock, in which case the request is proxied to your upstream instead.

Example

GET /users with two routes:

PriorityConditionResponse
10header X-Env equals staginga staging-flavored payload
0(none)the normal payload

A request with X-Env: staging gets the first route; every other request falls through to the unconditioned one.