Advanced
Request condition matching
In addition to URL patterns, you can match on detailed request conditions.

Condition types
| Type | Description | Example |
|---|---|---|
| Query parameter | Match on a URL query parameter | page=1 |
| Header | Match on a request header | Authorization: Bearer * |
| Body | Match on the request body content | {"type": "premium"} |
Operators
equalsExact match
containsPartial match
startsWithPrefix match
endsWithSuffix match
regexRegular expression match
existsKey existence check
Logical operators
You can combine multiple conditions.
ANDAll conditions must be met
ORAny condition is met
Configuration example
To match only "search requests from premium users":
URL Pattern: /api/search*
Method: GET
Conditions (AND):
- Query Parameter "q" exists
- Header "X-User-Type" equals "premium"Switching responses from the client side
When you want to prepare multiple response patterns for the same endpoint (success, error, empty data, and so on) and switch between them from the caller via test code or request headers, place several rules that use a dedicated header as their condition near the top of the list at a higher priority.
# Rule 1 (priority): error pattern
URL Pattern: /api/users/*
Conditions: Header "X-Mock-Response" equals "error"
Status: 500
# Rule 2 (priority): empty data pattern
URL Pattern: /api/users/*
Conditions: Header "X-Mock-Response" equals "empty"
Status: 200 / Body: []
# Rule 3 (default): no conditions
URL Pattern: /api/users/*
Status: 200 / Body: {normal response}If the caller sends the X-Mock-Response: error header, Rule 1 matches; if it sends nothing, Rule 3 (the default) matches. Rules are evaluated from top to bottom, so place variants with more specific conditions higher up. The same mechanism works with both a local proxy and Cloud Publish.
Pass-through
Even when a mock rule matches, this feature forwards the request to the real server.
Request pass-through
Forwards the request as-is to the real server. The response returned is what you configured in the mock rule.
Use case: When you want to send the request to the server but keep the response fixed (for example, always returning a specific response in an A/B test)
Response pass-through
Returns the real server's response as-is. The mock rule is used only for condition matching.
Use case: When you want to log traffic under specific conditions but not modify the response
Tip: When you enable both request pass-through and response pass-through, the rule is used only for condition matching and logging.
Response modification
You can partially modify the response from the real server.
Status code override
With response pass-through enabled, specifying a status code lets you override the real server's status code.
# Change to 500 even if the real server returns 200
Response pass-through: ON
Status code: 500Handy for testing error handling.
Response body merge
For JSON responses, you can merge the real server's response with the mock response.
# Real server response
{
"id": 1,
"name": "John",
"status": "active"
}
# Body configured in the mock (Merge Response Body: ON)
{
"status": "inactive",
"debug": true
}
# Final response
{
"id": 1,
"name": "John",
"status": "inactive",
"debug": true
}Network latency simulation
Simulate response latency to test how your app behaves under different network conditions.
Latency settings
Set the delay time in milliseconds in each rule's Delay (ms) field.
0No delay
5000.5 s
20002 s
1000010 s
Use cases
Loading state testing: Test whether the loading UI displays correctly
Timeout handling testing: Test whether timeout handling works correctly
Slow network simulation: Verify behavior on a slow network
Race condition testing: Test order-dependency problems across multiple requests
Note: The delay is applied even when response pass-through is enabled. The specified delay is added on top of the real server's response time.
OpenAPI import
Load an OpenAPI (YAML/JSON) definition file to auto-generate mock rules.

Supported formats
OpenAPI 3.xSupports the OpenAPI 3.0 / 3.1 specifications
YAML / JSONLoadable in either format
Key features
| Feature | Description |
|---|---|
| External reference resolution | $ref: './paths/users.yaml' and other external file references are resolved automatically |
| Automatic folder creation | Creates a folder per endpoint to organize the rules |
| Rule generation | Success responses (2xx) are created enabled; error responses (4xx/5xx) are created disabled |
Path conversion
OpenAPI path parameters are automatically converted to Mimicry wildcards.
# OpenAPI definition
/users/{userId}/posts/{postId}
# Converted to a Mimicry pattern
/users/*/posts/*Response generation
Response bodies are auto-generated in the following order of priority.
exampleWhen a single example is definedexamplesUses the first of multiple examplesschemaGenerates sample data from the schemaHow to use
- 1
Click the OpenAPI Import button in the sidebar
- 2
Select an OpenAPI definition file (YAML/JSON)
- 3
Review the folder and rule structure in the preview
- 4
Click the Import button to create all mock rules at once
Tip: You can check the folder structure and rule count in the preview before importing. Even large OpenAPI definitions with external references are resolved automatically and imported correctly.
Global headers
A global setting that always adds or removes headers on the requests and responses of matching domains. It works independently of mock rules and is applied before mock rules are evaluated, so it is also injected into requests that return a mock response.
Manage it in the dedicated modal opened from Global Rule Settings (the globe icon) at the bottom of the sidebar.
Settings
| Item | Description |
|---|---|
| Target domains | One entry per line. Wildcards ( *.example.com) are supported. If left empty, applies to all domains |
| Scope | When unselected, applies to all projects (global). When a project is selected, applies only while that project is active |
| Add / override on the request | Adds arbitrary headers to the request forwarded upstream |
| Remove from the request | Removes the specified headers before forwarding upstream |
| Add / override on the response | Adds arbitrary headers to the response returned to the client |
| Remove from the response | Removes the specified headers before returning to the client |
Use cases
Injecting a staging auth token:
Authorization: Bearer xxxis always injected, saving you from setting it manually every timeInjecting a debug header:
X-Debug-Tokenand similar headers are always added to correlate with server-side logs
Configuration example
To add an auth token to every API in the staging environment:
Name: Staging auth token
Target domains:
*.staging.example.com
Scope: (unselected → all projects)
Headers to add / override on the request:
Authorization: Bearer eyJhbGciOi...
X-Debug-Token: dev-localTip: Global headers are processed before mock rules are evaluated. Because they are also injected into requests that return a mock response, note that when combining them with header-based matching conditions, matching is judged on the post-injection values.
Template syntax and environment variables
You can embed {{ ... }} -style placeholders in a mock rule's response body, response headers, request-rewrite body, and request-rewrite headers. They are evaluated just before the matched request is returned and replaced with dynamic values.
Available placeholders
| Syntax | Expanded value |
|---|---|
{{now}} | Returns the current time in RFC3339 format |
{{now+3d}} / {{now-1h}} | Returns an offset from the current time in RFC3339. Units are d / h / m / s |
{{uuid}} | Generates a single UUID v4 |
{{random_int(min,max)}} | A random integer from min to max inclusive |
{{random_choice(a,b,c)}} | Randomly selects one of the comma-separated candidates |
{{random_date(YYYY-MM-DD,YYYY-MM-DD)}} | A random date within the specified range |
{{env.NAME}} | Replaced with the value of the global environment variable NAME |
Example in a response body
An example of returning a unique ID and timestamp every time:
{
"id": "{{uuid}}",
"createdAt": "{{now}}",
"expiresAt": "{{now+7d}}",
"score": {{random_int(1,100)}},
"status": "{{random_choice(active,pending,closed)}}"
}Global environment variables
A single key=value setting shared across all projects. You can reference it from a mock rule with the {{env.NAME}} syntax. Extract values that differ per environment (host names, tokens, tenant IDs, and so on) out of the mock rule body so you can switch them without rewriting the rule.
In the modal opened from Global Rule Settings (the globe icon) at the bottom of the sidebar, edit the keys and values in the Environment Variables section.
Configuration example
An example of defining the API host and region as environment variables:
# Global Rule Settings → Environment Variables
API_HOST = api.staging.example.com
REGION = ap-northeast-1
TENANT_ID = tenant-acme-001Reference them from a mock rule's response body:
{
"endpoint": "https://{{env.API_HOST}}/v1/users",
"region": "{{env.REGION}}",
"tenant": "{{env.TENANT_ID}}"
}You can also reference them from request-rewrite headers:
{
"X-Tenant-Id": "{{env.TENANT_ID}}",
"X-Region": "{{env.REGION}}"
}Use cases
Switching the API host: Embed
{{env.API_HOST}}as the URL in the response and swap only the value between staging and productionSwapping region and tenant: For multi-region or multi-tenant apps, switch via environment variables instead of embedding values in the rule itself
Separating secrets when sharing: Keep values such as auth tokens in environment variables and share only the mock rules with your team
Behavior on export / import
Environment variables are part of the global rule scope and are included in export / import.
- Existing keys take precedence: When a variable with the same name is already set at import time, the existing value is kept and not overwritten
- New keys are added: A key that exists only in the import source is added as-is
Tip: If you set machine-specific values (such as your personal access token) as environment variables locally, your settings are not overwritten even when you import mock rules shared by your team.
Scripts
A feature that dynamically transforms requests and responses with JavaScript. You can programmatically handle dynamic rewrites that mock rules can't express (adding a signature, rotating tokens, overwriting part of the body, and so on).
Open the dedicated window from Tools → Script... in the menu to create, edit, and enable scripts.
Hooks
Define the following functions in your script and they are called at the corresponding times.
| Hook | Timing | Return value |
|---|---|---|
onRequest(request) | Just before the request is sent upstream | Return a modified request to replace its contents |
onResponse(request, response) | Just before the response is returned to the client | Return a modified response to replace its contents |
Request/response objects
The objects passed to the hooks have the following structure.
// request
{
url: string, // e.g. "https://api.example.com/items?id=1"
method: string, // "GET" / "POST" / ...
headers: { [name: string]: string },
body: string, // text or base64 (when isBinary is true)
isBinary: boolean,
}
// response
{
statusCode: number, // e.g. 200
headers: { [name: string]: string },
body: string,
isBinary: boolean,
}Scope and activation
- Scope (URL pattern): Narrows down the target traffic using the same format as mock rules (e.g.,
api.example.com/*). - Enabled/disabled: Toggle per script. A disabled script is not run even if it matches.
- console output:
console.log/warn/errorare shown in real time in the console at the bottom of the script window. - Dry run: Test-run the script with a dummy request/response. You can check hook behavior and logs without sending real traffic.
Script example
An example that adds a signature to the request header and rewrites part of the response body:
// Scope: api.example.com/*
function onRequest(request) {
// Add a signature to the request
request.headers['X-Signature'] = 'sig-' + Date.now();
console.log('signed:', request.url);
return request;
}
function onResponse(request, response) {
// Overwrite part of the JSON response
if ((response.headers['content-type'] || '').includes('application/json')) {
try {
const json = JSON.parse(response.body);
json.debug = { injectedBy: 'mimicry-script' };
response.body = JSON.stringify(json);
} catch (e) {
console.warn('JSON parse failed:', e.message);
}
}
return response;
}Runtime environment
Scripts run in a sandbox and cannot directly access external resources (network or file system). Execution time and memory are capped, and each request is evaluated in an isolated context, so no state is shared between scripts or across calls.
Note: Binary bodies (images, videos, and so on) are passed as base64 strings with isBinary: true set. When rewriting the body, be careful to preserve the isBinary flag.