MockRoute Docs
Everything you need to create instant mock HTTP endpoints, define smart mocking rules, inspect request traffic, and forward to real backends.
Getting Started
1. Create an Endpoint
After signing up, click New Endpoint on your dashboard. Choose a subdomain — this becomes your unique base URL:
Your endpoint accepts any HTTP method at any path beneath this base URL — with no further configuration needed.
2. Make Your First Request
Hit your endpoint with any HTTP client:
If no mocking rule matches, you'll receive a
404 JSON
response. Define rules to customise the response.
Mocking Rules
Mocking rules define how MockRoute responds to incoming requests. Each rule specifies a method + path combination and the response to return.
| Field | Description | Example |
|---|---|---|
| Name | Human-readable label for the rule | Get all users |
| Method | HTTP method to match | GET, POST, PUT… |
| Path | URL path to match (supports wildcards) | /users, /users/* |
| Status Code | HTTP response status to return | 200, 201, 404, 500 |
| Response Body | JSON or any text body to return | {"users":[]} |
| Response Headers | Extra headers on the response | X-Custom: value |
| Delay | Simulate slow APIs (ms) | 500 → 500ms delay |
| Priority | Higher = matched first when paths overlap | 10 |
Path Matching
Paths are matched against the
portion of the URL after your subdomain. Use * as a
wildcard segment.
/users
Exact match — only /users
/users/*
Matches /users/1, /users/abc, etc.
/users/1
Exact match — only /users/1
/orders/*/items
Matches /orders/5/items
Priority
When multiple rules match the same
request, the rule with the highest priority
number wins. Default priority is 0. Set
priority 10
on a rule to ensure it takes precedence over others with 0.
Simulating Delay
Set a delay (in milliseconds) on a rule to simulate slow network or database conditions. Useful for testing loading states and timeout handling in your UI.
Request Logs
Every request to your endpoint is captured and stored. The logs page gives you a full breakdown including method, path, matched rule, status code, response time, and timestamps.
Request Inspector
Click any row in the logs table to open the Request Inspector. It shows four tabs:
- Request Body — the payload sent to your endpoint
- Response Body — what MockRoute returned
- Request Headers — all headers from the caller
- Response Headers — headers included in the response
Clearing Logs
Use the Clear All Logs button on the logs page to permanently delete all request history for an endpoint. This action is irreversible.
Request Forwarding Pro
Request Forwarding proxies all incoming requests to a real backend URL and returns the real response — while still logging the full request/response in MockRoute. Perfect for intercepting and inspecting live traffic.
Setup
- Open your endpoint's detail page
- Scroll to Request Forwarding and toggle it on
- Enter your target URL (e.g.
https://api.example.com) - Save — all requests will now be proxied to that URL
OpenAPI Import Pro
The OpenAPI Import feature lets you upload an OpenAPI 3.x or Swagger 2.0 specification file and instantly generate a full set of mocking rules — one per operation defined in your spec. No manual rule creation required.
Import Steps
- Open an endpoint's detail page and click Import OpenAPI
- Paste your spec as JSON/YAML or drag-and-drop a
.json/.yamlfile - MockRoute parses every
path + methodcombination and creates a mocking rule for each - Response bodies are auto-generated from the spec's
schema.examplevalues where available, otherwise sensible defaults are used - Review and edit the generated rules as needed
Notes & Limits
- Supports OpenAPI 3.0 / 3.1 and Swagger 2.0
- Path parameters (e.g.
/users/{id}) are converted to wildcard rules (/users/*) - Existing rules with the same method + path are overwritten during import
- Maximum spec file size: 1 MB
- External
$refreferences to remote URLs are not resolved during import
Dynamic Responses Pro
Dynamic Responses let you embed template expressions directly in your rule's response body. Each request evaluates the template fresh, producing randomised or request-contextual data — without writing any backend code.
Template Syntax
Use {{ expression }}
placeholders in your response body. Available helpers, grouped by category:
General
| Expression | Output |
|---|---|
| {{ faker.uuid }} | A random UUID v4 |
| {{ faker.name }} | A random full name |
| {{ faker.id }} | A random integer ID between 1 and 100,000 |
| {{ faker.integer(1,100) }} | Random integer between 1 and 100 |
| {{ faker.float(1,100) }} | Random decimal number between 1 and 100 |
| {{ faker.boolean }} | true or false randomly |
| {{ faker.isoDate }} | Current timestamp in ISO 8601 |
| {{ faker.paragraph }} | A random lorem ipsum paragraph |
| {{ faker.address }} | A random full street address |
| {{ faker.country }} | A random country name |
| {{ faker.city }} | A random city name |
Person
| Expression | Output |
|---|---|
| {{ faker.firstName }} | A random first name |
| {{ faker.lastName }} | A random last name |
| {{ faker.gender }} | "male" or "female" randomly |
| {{ faker.email }} | A random email address |
| {{ faker.phoneNumber }} | A random phone number |
| {{ faker.profileImage }} | A random profile image URL |
| {{ person.bio }} | A short random bio sentence |
| {{ person.firstName }} | A random first name |
| {{ person.lastName }} | A random last name |
| {{ person.middleName }} | A random middle name |
| {{ person.fullName }} | A random full name |
| {{ person.gender }} | "male" or "female" randomly |
| {{ person.sex }} | "male" or "female" randomly |
| {{ person.sexType }} | "Male" or "Female" randomly |
| {{ person.prefix }} | A random name prefix (e.g. Mr., Dr.) |
| {{ person.suffix }} | A random name suffix (e.g. Jr., PhD) |
| {{ person.jobTitle }} | A random job title |
| {{ person.jobArea }} | A random job department (e.g. Engineering) |
| {{ person.jobDescriptor }} | A random job descriptor (e.g. Senior) |
| {{ person.jobType }} | A random job type (e.g. Manager) |
| {{ person.zodiacSign }} | A random zodiac sign |
Finance
| Expression | Output |
|---|---|
| {{ finance.accountNumber }} | A random 10-digit account number |
| {{ finance.amount }} | A random monetary amount |
| {{ finance.bic }} | A random SWIFT/BIC code |
| {{ finance.bitcoinAddress }} | A random Bitcoin address |
| {{ finance.creditCardCVV }} | A random 3-digit CVV |
| {{ finance.creditCardIssuer }} | A random card issuer (e.g. Visa) |
| {{ finance.creditCardNumber }} | A random credit card number |
| {{ finance.currency }} | A random 3-letter currency code |
| {{ finance.currencyCode }} | A random 3-letter currency code |
| {{ finance.currencyName }} | A random currency name (e.g. US Dollar) |
| {{ finance.currencySymbol }} | A random currency symbol (e.g. $) |
| {{ finance.ethereumAddress }} | A random Ethereum address |
| {{ finance.iban }} | A random IBAN |
| {{ finance.litecoinAddress }} | A random Litecoin address |
| {{ finance.pin }} | A random 4-digit PIN |
| {{ finance.routingNumber }} | A random 9-digit routing number |
| {{ finance.transactionDescription }} | A random transaction description |
| {{ finance.transactionType }} | A random transaction type (e.g. deposit) |
Internet
| Expression | Output |
|---|---|
| {{ internet.color }} | A random hex color |
| {{ internet.displayName }} | A random display/username |
| {{ internet.domainName }} | A random domain name |
| {{ internet.domainSuffix }} | A random domain suffix (e.g. .com) |
| {{ internet.email }} | A random email address |
| {{ internet.emoji }} | A random emoji |
| {{ internet.httpMethod }} | A random HTTP method |
| {{ internet.httpStatusCode }} | A random HTTP status code |
| {{ internet.ip }} | A random IPv4 address |
| {{ internet.ipv4 }} | A random IPv4 address |
| {{ internet.ipv6 }} | A random IPv6 address |
| {{ internet.mac }} | A random MAC address |
| {{ internet.password }} | A random password string |
| {{ internet.port }} | A random port number (1-65535) |
| {{ internet.protocol }} | A random protocol (e.g. https) |
| {{ internet.url }} | A random URL |
| {{ internet.userAgent }} | A random browser user agent string |
| {{ internet.userName }} | A random username |
Vehicle
| Expression | Output |
|---|---|
| {{ vehicle.bicycle }} | A random bicycle type |
| {{ vehicle.color }} | A random vehicle color |
| {{ vehicle.fuel }} | A random fuel type |
| {{ vehicle.manufacturer }} | A random vehicle manufacturer |
| {{ vehicle.model }} | A random vehicle model |
| {{ vehicle.type }} | A random vehicle body type |
| {{ vehicle.vehicle }} | A random manufacturer + model |
| {{ vehicle.vin }} | A random 17-character VIN |
| {{ vehicle.vrm }} | A random UK-style registration plate |
Animal
| Expression | Output |
|---|---|
| {{ animal.bear }} | A random bear species |
| {{ animal.bird }} | A random bird species |
| {{ animal.cat }} | A random cat breed |
| {{ animal.cetacean }} | A random whale/dolphin species |
| {{ animal.cow }} | A random cattle breed |
| {{ animal.crocodilia }} | A random crocodilian species |
| {{ animal.dog }} | A random dog breed |
| {{ animal.fish }} | A random fish species |
| {{ animal.horse }} | A random horse breed |
| {{ animal.insect }} | A random insect |
| {{ animal.lion }} | A random lion subspecies |
| {{ animal.rabbit }} | A random rabbit breed |
| {{ animal.rodent }} | A random rodent |
| {{ animal.snake }} | A random snake species |
| {{ animal.type }} | A random animal class (e.g. Mammal) |
Music
| Expression | Output |
|---|---|
| {{ music.genre }} | A random music genre |
| {{ music.songName }} | A random song title |
Request Context
| Expression | Output |
|---|---|
| {{ request.method }} | The HTTP method of the request |
| {{ request.path }} | The path of the incoming request |
| {{ request.header.X-User-Id }} | Value of a specific request header |
| {{ request.body.name }} | Top-level field from a JSON request body |
Examples
Create user — echo back a generated ID and the submitted name:
"id": "{{ faker.uuid }}",
"name": "{{ request.body.name }}",
"createdAt": "{{ faker.isoDate }}"
}
List endpoint — return a random number of items:
"total": "{{ faker.integer(1, 50) }}",
"items": []
}
Stateful Mock Servers Pro
Stateful Mock Servers allow your endpoint to remember data across requests. Instead of always returning a fixed response, the server maintains an in-memory store that your rules can read from and write to — simulating real CRUD behaviour.
Setup
- Open your endpoint's detail page and enable Stateful Mode in the settings panel
- Define a seed dataset — the
initial in-memory state as a JSON object (e.g.
{"users": []}) - Use the state helpers in your rule response bodies:
| Helper | Description |
|---|---|
| {{ state.get("users") }} | Return the current value of the users key |
| {{ state.push("users", request.body) }} | Append the request body to the users array |
| {{ state.set("users", []) }} | Overwrite a key with a new value |
| {{ state.delete("users", request.path[2]) }} | Remove item by ID from a collection |
State is scoped per endpoint and persists for the lifetime of the session. Multiple concurrent clients share the same state, making it suitable for collaborative testing scenarios.
Resetting State
You can reset the endpoint state at any time:
- Dashboard reset — click Reset State on the endpoint settings page to restore to the seed dataset
- API reset — send
DELETE https://mockroute.com/mock/{subdomain}/_statewith your API key to reset programmatically (useful in CI/CD pipelines) - Auto-reset — optionally configure state to auto-reset after a set idle period (1h, 24h, or on each test run via the API)
# Reset state via API (e.g. in a CI teardown step)
curl -X DELETE \
-H
"X-Api-Key: YOUR_API_KEY" \
https://mockroute.com/mock/my-app/_state
API Reference
The MockRoute mock handler accepts all requests at the following pattern:
Authentication
Mock endpoint URLs require no authentication — they are publicly accessible by subdomain. Protect sensitive endpoints at the application level using mocking rule conditions.
Examples
REST API Mock — Users
Create these rules on an endpoint with
subdomain my-api:
| Method | Path | Status | Body |
|---|---|---|---|
| GET | /users | 200 | {"users": [{"id":1,"name":"Alice"}]} |
| POST | /users | 201 | {"id": 2, "name": "Bob"} |
| GET | /users/* | 200 | {"id": 1, "name": "Alice"} |
| DELETE | /users/* | 204 | (empty) |
cURL Examples
# List users
curl <?php echo e(url('/mock/my-api/users')); ?>
# Create user
curl -X POST -H "Content-Type: application/json" -d '{"name":"Alice"}' <?php echo e(url('/mock/my-api/users')); ?>
# Get one user
curl <?php echo e(url('/mock/my-api/users/1')); ?>
# Delete user
curl -X DELETE <?php echo e(url('/mock/my-api/users/1')); ?>