Skip to Content
Advanced FeaturesDynamic Interceptors

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
FlagDefaultDescription
--nameInterceptor name (required)
--matchMatch expression in DSL syntax (required)
--actionobserveAction: mock, modify, observe
--description""Human-readable description

List interceptors

apxy rules interceptor list

Remove 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 json

Combine with && (AND) and || (OR):

host == api.example.com && method == POST path contains /users || path contains /accounts

Special values: * or true match everything.

Actions

ActionDescription
mockReturn a fake response without forwarding to the server
modifyForward to the server but alter the request or response
observeForward normally and log the match (no transformation)

Transform Options

When using mock or modify actions, you can specify transforms:

FieldDescription
set_request_headersOverwrite request headers
set_response_headersOverwrite response headers
set_response_statusOverride response status code
set_response_bodyOverride response body
add_request_headersAdd headers without overwriting
remove_headersHeader names to remove
delay_msDelay before responding

Use Cases

Add debug headers to staging requests

apxy rules interceptor set --name "debug-staging" \ --match "host == staging.example.com" \ --action modify

Then 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 mock
Last updated on