Mock Rules
Intercept matching requests and return fake responses instead of hitting the real server. Perfect for offline development, testing error states, and simulating API behavior.
Mock rules are static. They can match by URL, method, and request headers, but they do not maintain server-side state or branch on request bodies.
Web UI
Open Mock Rules from the Modify group. The page provides:
- A form to create mock rules with Name, URL Pattern, Match Type (exact/wildcard/regex), Method, Header Conditions, Status Code, Response Headers, Response Body, File Path, Directory Path, Delay, and Priority
- A list of all mock rules with enable/disable toggles
- Edit and delete buttons for each rule
- Active/inactive status indicators
When you create a mock rule for an HTTPS URL, APXY automatically enables SSL interception for that domain.
CLI
All apxy mock … subcommands (add, list, enable, disable, remove, clear) and flags are documented in CLI Reference → Mock.
Quick example:
apxy mock add \
--name "Mock Users" \
--url "https://api.example.com/api/users" \
--match exact \
--status 200 \
--body '{"users": [{"id": 1, "name": "Test User"}]}'Match types
| Type | Description | Example |
|---|---|---|
exact | URL must match exactly | /api/users matches only /api/users |
wildcard | * matches any characters | /api/* matches /api/users, /api/posts |
regex | Full regular expression | /api/users/\d+ matches /api/users/123 |
Use Cases
Testing error handling
Add a mock rule that returns 5xx or 4xx responses for a path you need to exercise in the client.
Offline development
Stub critical endpoints with small JSON bodies so the app runs without the real backend.
Simulating slow responses
Use the Delay field (or --delay in the CLI) to mimic sluggish upstream APIs.