Skip to content

Mock Rules

Mock rules let a single endpoint return different responses depending on the incoming request. Rules are evaluated in order — the first match wins.

From the endpoint detail page, click Add Rule. Each rule has:

  • Conditions — what to match on (headers, query params, body)
  • Response — the status code and body to return when conditions match
TypeExampleMatches when…
HeaderAuthorization: Bearer token123Request header matches the value
Query Parameterstatus=activeQuery string parameter matches
Body (JSON path)$.user.role = "admin"JSON body field matches

Rules are checked top-to-bottom. The first rule whose conditions all match is used. If no rules match, the endpoint’s default response is returned.

An endpoint at GET /api/users with two rules:

  1. If query param status=active then return 200 with active users JSON
  2. If query param status=inactive then return 200 with inactive users JSON
  3. Default: return 200 with all users JSON