Skip to Content

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 script

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 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 name

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 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 --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 script 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 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 onResponse

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 edit --hook string hook: onRequest or onResponse --match string DSL match expression --name string script name

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 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 --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 script 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 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 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 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 --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 script 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 script - Create and manage proxy scripts for the running proxy
Last updated on