Skip to Content

Mock rules intercept matching requests and return a canned response — without the request ever reaching the real server. Use mocks to simulate error states, test edge cases, or stub out services that are not available in your local environment.

Rules are matched in priority order (lower number = higher priority). Use --priority to control which rule wins when multiple rules match the same request.

apxy mock

Create and manage mock response rules

Options

-h, --help help for mock

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

apxy mock add

Add a mock response rule

Synopsis

Create a mock response rule that intercepts matching requests and returns a canned response.

Flags: —name rule name for identification —url URL pattern to match against incoming requests —match match type: exact, wildcard, or regex (default: exact) —method HTTP method filter (e.g. GET, POST) —header-conditions request header matchers as JSON or k=v pairs —headers response headers as JSON or k=v pairs —status response status code (default: 200) —body response body string —delay artificial response delay in milliseconds —priority rule priority (lower values match first)

apxy mock add [flags]

Examples

apxy mock add --name "mock-users" --url "https://api.example.com/users" --method GET --status 200 --body '{"users":[]}' apxy mock add --name "stripe-card-decline" --url "https://api.stripe.com/v1/payment_intents/*/confirm" --match wildcard --method POST --header-conditions 'X-APXY-Scenario=card_declined' --status 402 --body '{"error":{"type":"card_error"}}' apxy mock add --name "slow-api" --url "https://api.example.com/*" --match wildcard --status 200 --body '{}' --delay 2000

Options

--body string response body --control-url string control API URL (default "http://127.0.0.1:8081") --delay int response delay in ms --header-conditions string request header conditions as JSON or k=v,k2=v2 --headers string response headers as JSON or k=v,k2=v2 -h, --help help for add --match string match type: exact|wildcard|regex (default "exact") --method string HTTP method filter --name string rule name --priority int rule priority (lower values match first) --status int response status code (default 200) --url string URL pattern

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock clear

Delete all mock rules

Synopsis

Delete ALL mock response rules from the running proxy.

WARNING: This action cannot be undone.

apxy mock clear [flags]

Examples

apxy mock clear

Options

--control-url string control API URL (default "http://127.0.0.1:8081") --dry-run preview what would happen without executing -h, --help help for clear

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock disable

Disable a mock rule

Synopsis

Disable a mock rule without removing it, or disable all mock rules with —all. Disabled rules are ignored during matching.

Either —id or —all is required. Use “apxy mock list” to find rule IDs.

apxy mock disable [flags]

Examples

apxy mock disable --id abc123 apxy mock disable --all

Options

--all apply to all resources --control-url string control API URL (default "http://127.0.0.1:8081") --dry-run preview what would happen without executing -h, --help help for disable --id string rule ID

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock edit

Edit a mock response rule

Synopsis

Edit an existing mock rule. Only the flags you supply are updated; all other fields remain unchanged.

Flags: —name rule name —url URL pattern —match match type: exact, wildcard, or regex —method HTTP method filter —header-conditions request header matchers as JSON or k=v pairs —headers response headers as JSON or k=v pairs —status response status code —body response body string —delay response delay in milliseconds —priority rule priority (lower values match first)

apxy mock edit <id> [flags]

Examples

apxy mock edit abc123 --status 404 --body '{"error":"not found"}' apxy mock edit abc123 --delay 2000 apxy mock edit abc123 --url "https://api.example.com/v2/users" --match wildcard

Options

--body string response body --control-url string control API URL (default "http://127.0.0.1:8081") --delay int response delay in ms --header-conditions string request header conditions as JSON or k=v,k2=v2 --headers string response headers as JSON or k=v,k2=v2 -h, --help help for edit --match string match type: exact|wildcard|regex --method string HTTP method filter --name string rule name --priority int rule priority (lower values match first) --status int response status code --url string URL pattern

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock enable

Enable a mock rule

Synopsis

Re-enable a previously disabled mock rule by its unique ID, or enable all mock rules with —all.

Either —id or —all is required. Use “apxy mock list” to find rule IDs.

apxy mock enable [flags]

Examples

apxy mock enable --id abc123 apxy mock enable --all

Options

--all apply to all resources --control-url string control API URL (default "http://127.0.0.1:8081") --dry-run preview what would happen without executing -h, --help help for enable --id string rule ID

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock import

Import mock rules from a JSON template file

Synopsis

Import multiple mock rules from a JSON template file in a single command.

The file must contain a JSON array of mock rule objects matching the template format (see https://github.com/apxydev/apxy/tree/main/mock-templates  for examples).

All rules are validated upfront before any are applied. If validation fails, no rules are imported.

apxy mock import [flags]

Examples

apxy mock import --file templates/github-api/rules.json apxy mock import --file templates/stripe/rules.json --control-url http://localhost:9081

Options

--control-url string control API URL (default "http://127.0.0.1:8081") --file string path to rules JSON file (required) -h, --help help for import

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock list

List mock rules

Synopsis

List all configured mock response rules, including their IDs, names, URL patterns, and status.

Flags: —format output format: json or toon (default: json)

apxy mock list [flags]

Examples

apxy mock list apxy mock list --format toon

Options

--control-url string control API URL (default "http://127.0.0.1:8081") --format string output format: json|toon (default "json") -h, --help help for list -q, --quiet output only IDs, one per line

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules

apxy mock remove

Remove a mock rule by ID or all mock rules

Synopsis

Remove a mock response rule by its unique ID, or remove all mock rules with —all.

Either —id or —all is required. Use “apxy mock list” to find rule IDs.

apxy mock remove [flags]

Examples

apxy mock remove --id abc123 apxy mock remove --all

Options

--all apply to all resources --control-url string control API URL (default "http://127.0.0.1:8081") --dry-run preview what would happen without executing -h, --help help for remove --id string rule ID

Options inherited from parent commands

--config string config file (default is ./configs/default.yaml) --error-format string error output format: text|json (default "text") --help-format string help output format: default|agent (default "default") --output string output format: agent|human (default: auto-detect via TTY) --verbose enable verbose output

SEE ALSO

  • apxy mock - Create and manage mock response rules
Last updated on