Mockzilla logo

Routing & Matching Reference

Mockzilla's routing engine gives you full control over how your incoming requests match your mocks. This means you can create multiple responses for the same path based on URL segments or query parameters.

Path Matching Strategies

StrategyDescriptionBest Use Case
ExactPath must match character-for-character.Static routes: /login, /profile.
WildcardUse * to capture dynamic URL segments.Routes with IDs: /users/*, /posts/*/comments.
SubstringMatches if the mock path is contained anywhere in the URL.General prefixes: /api/v1 to catch everything under it.

Wildcard Variants

With Wildcard Match Type, you can return different data for different captured segments.

Single Wildcard

On /users/*:

  • Key: 1 -> Returns Gold Member profile.
  • Key: 2 -> Returns Basic Member profile.
  • Key: * -> Returns a default 404 or Generic User.

Multiple Wildcards

If you use multiple *, the Variant Key is formed by joining captured segments with a pipe (|).

Example Pattern: /api/users/*/orders/*

Request PathCaptured SegmentsVariant Key to Use
/api/users/123/orders/456123, 456`123
/api/users/alice/orders/latestalice, latest`alice

Matching by Query Parameters

You can enforce strict matching based on the Query String.

  1. In Advanced Options, add a Key (e.g., role) and a Value (e.g., admin).
  2. Mockzilla will only serve this mock if the incoming URL includes ?role=admin.
  3. You can stack multiple parameters for complex test cases (e.g., ?role=admin&beta=true).

You can also type query parameters directly in the Endpoint Path field, such as /users?role=admin. Mockzilla keeps that full URL-style path visible in the editor, syncs it with Advanced Options, and updates the preview URL as you edit either place.


Strategy Precedence

If multiple mocks could match a single request, Mockzilla follows this precedence:

  1. Exact (Highest priority)
  2. Wildcard
  3. Substring

Proxy & Record

When a matched mock has meta.proxyTargetUrl:

  1. It proxies the request to that URL.
  2. It auto-captures the response.
  3. It creates a new exact mock in the same folder.

If no mock matches, Mockzilla returns 404; proxy recording is never enabled by folder metadata.

See the Proxy & Record Guide for more.


FAQ: Handling URL Overlap

  • Scenario: I have /users/admin (Exact) and /users/* (Wildcard).
  • Answer: Mockzilla will always pick the Exact match first. Only if the path is not "admin" (e.g., /users/123) will it move to the Wildcard match.