Skip to content
←  Home 日本語

Mock Rules

Basic concepts

In Mimicry, mock rules are organized in a hierarchy.

The folder structure of mock rules: projects, folders, and rules shown as a hierarchy in a tree view
Project- The top-level unit of organization (e.g., MyApp)
Folder- Groups rules together (e.g., Users API)
Rule- An individual mock rule

Each rule can be toggled on or off; a disabled rule is no longer applied.

Creating a rule

The mock rule editor showing setting fields for the URL pattern, HTTP method, status code, and response body
1

Select the folder to add the rule to in the left sidebar.

2

Set the URL pattern, HTTP method, and response.

3

Click the Save button to save the rule.

4

Make sure the rule is enabled (toggle switch).

Settings

URL pattern

Specify a pattern that matches the request URL. You can use wildcards (* and **).

# Exact match
https://api.example.com/users

# Single-segment wildcard
https://api.example.com/users/*

# Multi-segment wildcard
https://api.example.com/**

# Match by path only, on any host
/api/users/**

# Domain wildcard
https://*.example.com/api/*
  • A pattern starting with http:// or https:// is matched against the whole URL, host included. A pattern starting with / is matched against the path (and query) only, on any host.
  • * does not cross /. Use ** to match across multiple segments.
  • The whole path has to match; it is not a prefix match. /api/users/* matches /api/users/42 but not /api/users/42/posts.
  • A trailing slash is significant: /api/users and /api/users/ are different paths.
  • Case is ignored for ASCII characters only.
  • The query is checked only when the pattern has one, and then as a subset: the parameters you wrote must be present in the request. A pattern without a query ignores the request's query.

HTTP method

Specify the HTTP method to match.

All methodsGETPOSTPUTPATCHDELETEHEADOPTIONS

Selecting "All methods" matches every HTTP method.

Status code

Specify the status code of the response. Common codes are available as presets, and selecting "Custom" at the end of the list lets you enter any code from 100 to 599 directly.

200OK
201Created
204No Content
301Moved Permanently
302Found
400Bad Request
401Unauthorized
403Forbidden
404Not Found
500Internal Server Error
502Bad Gateway
503Service Unavailable

Response headers

Specify the response headers in JSON format.

{
  "Content-Type": "application/json",
  "Cache-Control": "no-cache"
}

Response body

Set the response body. You can specify it in any format, such as JSON, text, or HTML.

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com"
}

Delay (milliseconds)

Specify the delay in milliseconds before the response is returned. Use it to test network latency and timeout handling.

Example:050020005000

Projects and folders

Creating projects and folders

You can create a project or folder from the + button at the top of the left sidebar.

Duplicating a rule

Duplicate an existing rule to create similar rules efficiently.

  1. Right-click the rule you want to duplicate
  2. Select "Duplicate"
  3. A rule with the same settings is created

This is handy when creating multiple rules with similar URL patterns or responses.

Drag & drop

You can reorder rules and folders by drag and drop. You can also move rules between multiple projects.

Enabling and disabling

Each rule has an enable/disable toggle switch. A disabled rule does not match requests.

Rule priority

When multiple rules match, the rule higher in the list takes precedence.

Hint: We recommend placing more specific rules (such as exact matches) higher and general rules (wildcards) lower.

A project the CLI wrote to with --project is matched ahead of the other projects, wherever it sits in the sidebar (pinned). You can unpin it from the PIN badge or the right-click menu in the sidebar.

Temporary rules

Add --ttl to the CLI's rule set and the rule is deleted automatically once the time has passed. Add --times and it is deleted after being applied N times. You can see how many times it has been applied in ruleUse of mimicry logs --json. The GUI sidebar shows a "Temp · … left" badge, and "Keep permanently" keeps the rule.