Scripts let you attach JavaScript logic to the proxy pipeline — inspect, modify, or mock requests and responses programmatically. Scripts run in a sandboxed environment with access to the full request and response objects.
Use script enable and script disable to toggle scripts without removing them. This is
useful for keeping a set of scripts ready and activating them as needed.
apxy script
Create and manage proxy scripts for the running proxy
Options
-h, --help help for scriptOptions 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 outputSEE ALSO
- apxy - HTTPS proxy for capturing, inspecting, and modifying API traffic
- apxy script add - Add a proxy script
- apxy script disable - Disable a proxy script
- apxy script edit - Edit a proxy script
- apxy script enable - Enable a proxy script
- apxy script list - List proxy scripts
- apxy script remove - Remove a proxy script by ID or all scripts
apxy script add
Add a proxy script
Synopsis
Add a JavaScript proxy script that runs on matching requests or responses.
Provide the script via —file (path to a .js file) or —code (inline JavaScript).
Flags: —name script name (required) —file path to JavaScript file —code inline JavaScript code —hook hook point: onRequest or onResponse (default: onResponse) —match DSL match expression (default: *)
apxy script add [flags]Examples
apxy script add --name "log-headers" --file ./scripts/log-headers.js --hook onRequest
apxy script add --name "rewrite-body" --code 'response.body = response.body.replace("foo","bar")' --match "host == api.example.com"Options
--code string inline JavaScript code
--control-url string control API URL (default "http://127.0.0.1:8081")
--file string path to JavaScript file
-h, --help help for add
--hook string hook: onRequest or onResponse (default "onResponse")
--match string DSL match expression (default "*")
--name string script nameOptions 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 outputSEE ALSO
- apxy script - Create and manage proxy scripts for the running proxy
apxy script disable
Disable a proxy script
Synopsis
Disable a proxy script without removing it, or disable all scripts with —all. Disabled scripts are skipped during execution.
Either —id or —all is required. Use “apxy script list” to find script IDs.
apxy script disable [flags]Examples
apxy script disable --id abc123
apxy script disable --allOptions
--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 script IDOptions 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 outputSEE ALSO
- apxy script - Create and manage proxy scripts for the running proxy
apxy script edit
Edit a proxy script
Synopsis
Edit an existing proxy script. Only the flags you supply are updated; all other fields remain unchanged.
Provide new script code via —file (path to a .js file) or —code (inline JavaScript).
Flags: —name script name —file path to JavaScript file —code inline JavaScript code —hook hook point: onRequest or onResponse —match DSL match expression
apxy script edit <id> [flags]Examples
apxy script edit abc123 --file ./scripts/log-headers-v2.js
apxy script edit abc123 --code 'response.headers["X-Test"]="1"'
apxy script edit abc123 --match "host == api.example.com" --hook onResponseOptions
--code string inline JavaScript code
--control-url string control API URL (default "http://127.0.0.1:8081")
--file string path to JavaScript file
-h, --help help for edit
--hook string hook: onRequest or onResponse
--match string DSL match expression
--name string script nameOptions 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 outputSEE ALSO
- apxy script - Create and manage proxy scripts for the running proxy
apxy script enable
Enable a proxy script
Synopsis
Re-enable a previously disabled proxy script by its unique ID, or enable all scripts with —all.
Either —id or —all is required. Use “apxy script list” to find script IDs.
apxy script enable [flags]Examples
apxy script enable --id abc123
apxy script enable --allOptions
--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 script IDOptions 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 outputSEE ALSO
- apxy script - Create and manage proxy scripts for the running proxy
apxy script list
List proxy scripts
Synopsis
List all configured proxy scripts, including their IDs, names, hooks, and enabled status.
Flags: —format output format: json or toon (default: json)
apxy script list [flags]Examples
apxy script list
apxy script list --format toonOptions
--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 lineOptions 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 outputSEE ALSO
- apxy script - Create and manage proxy scripts for the running proxy
apxy script remove
Remove a proxy script by ID or all scripts
Synopsis
Remove a proxy script by its unique ID, or remove all scripts with —all.
Either —id or —all is required. Use “apxy script list” to find script IDs.
apxy script remove [flags]Examples
apxy script remove --id abc123
apxy script remove --allOptions
--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 script IDOptions 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 outputSEE ALSO
- apxy script - Create and manage proxy scripts for the running proxy