Dynamic Interceptors
APXY provides Dynamic Interceptors — a programmable system for matching traffic and applying transformations using a DSL (Domain-Specific Language). Unlike static mock rules, interceptors support conditional logic and can modify requests and responses on-the-fly.
Paid feature — requires a license with interceptor editing capability.
Web UI
Open Interceptors from the Modify group. The page provides:
- A form to create interceptors with Name, Match Expression (DSL syntax), Action dropdown (mock / modify / observe), and optional Transform fields for headers, status, body, and delay
- A list of active interceptors with enable/disable toggles
- Delete buttons for each interceptor
CLI
Create an interceptor
apxy rules interceptor set --name "debug-staging" \
--match "host == staging.example.com" \
--action observe| Flag | Default | Description |
|---|---|---|
--name | — | Interceptor name (required) |
--match | — | Match expression in DSL syntax (required) |
--action | observe | Action: mock, modify, observe |
--description | "" | Human-readable description |
List interceptors
apxy rules interceptor listRemove an interceptor
apxy rules interceptor remove --id <id>Match Expression DSL
Match expressions filter traffic based on request/response properties:
host == api.example.com
path contains /api/v2/
method == POST
status >= 400
url matches .*\.json$
header:Content-Type contains jsonCombine with && (AND) and || (OR):
host == api.example.com && method == POST
path contains /users || path contains /accountsSpecial values: * or true match everything.
Actions
| Action | Description |
|---|---|
mock | Return a fake response without forwarding to the server |
modify | Forward to the server but alter the request or response |
observe | Forward normally and log the match (no transformation) |
Transform Options
When using mock or modify actions, you can specify transforms:
| Field | Description |
|---|---|
set_request_headers | Overwrite request headers |
set_response_headers | Overwrite response headers |
set_response_status | Override response status code |
set_response_body | Override response body |
add_request_headers | Add headers without overwriting |
remove_headers | Header names to remove |
delay_ms | Delay before responding |
Use Cases
Add debug headers to staging requests
apxy rules interceptor set --name "debug-staging" \
--match "host == staging.example.com" \
--action modifyThen configure the transform to add X-Debug-Proxy: true to matching requests.
Log all POST requests
apxy rules interceptor set --name "log-posts" \
--match "method == POST" \
--action observe \
--description "Track all form submissions and API writes"Mock errors for specific conditions
apxy rules interceptor set --name "error-auth" \
--match "path contains /api/auth && method == POST" \
--action mockLast updated on