Skip to content

The command line

ReferenceFacts to look up.

apinxctl talks to the Admin API; apinx is the server with a few local commands.

apinxctl

export APINX_SERVER=http://localhost:9000
export APINX_TOKEN=$(APINX_PASSWORD='…' apinxctl login --email admin@example.com)
Command What it does
login --email E --password P Sign in and print a bearer token (prefer APINX_PASSWORD in the environment)
get apis · shared-flows · policy-usage · products · subscriptions · upstreams · listeners · routes · revisions · audit · users · status · applications · policies · errors Read the draft, history, audit, consumers, the policy catalogue and the error reference
export The draft as apinx/v1 YAML on stdout
import <file\|-> Replace the draft from a file or stdin
diff The draft against the deployed configuration
validate [file] Compile the draft on the server, or a file locally
publish [-m MSG] [--force] Deploy the draft as a new revision
rollback <sequence> Make an earlier revision the deployed one
version Build identity of the client

Flags --server and --token override the environment. Output is JSON for get and YAML for export, so jq and yq compose well:

apinxctl get apis | jq -r '.[].name'
apinxctl get audit | jq '.[] | select(.action == "delete")'

apinx

Command What it does
apinx --config FILE Run the server
apinx --help Every flag with its default and environment variable
apinx version Build identity
apinx config show The effective process configuration, secrets redacted
apinx config reference The generated table of every setting
apinx gateway validate [file] Validate a gateway document without a server
apinx gateway run [file] Serve the file alone, watched and reloaded: no store, no console (file mode)

Both gateway commands read the file with its ${NAME} and ${NAME:-default} environment references expanded; an unset variable without a default is reported as APX-GW-0012. | apinx gateway audit [file] | Say what a gateway document shows that is worth a look, without a server |

Any setting can be given as a flag or an environment variable; precedence is flag, environment, file, default:

APINX_LOGGING_LEVEL=debug apinx --console.listen 127.0.0.1:9001

Audit the configuration

apinx gateway audit [file] reads a gateway document the way validate does and prints what an API owner should look at before publishing it: operations anyone can call, no rate limit, listeners without TLS, backends reached in the clear, retries that can repeat a write. The file defaults to gateway.yaml in the current directory. Findings are grouped by severity, most pressing first, each with the objects to change and what to do:

$ apinx gateway audit gateway.yaml
gateway.yaml: 4 findings (1 high, 2 medium, 1 low)

High (look now)
- Operations anyone can call: route orders-get, route orders-list
    These operations run no api-key, jwt or basic policy, their own or inherited, so anyone who
    knows the address can call them. Bind one on the API, or on the global level for the whole
    gateway, and switch it off only on the operations that must stay open, such as a login or a
    health check.

Medium (worth a look)
- No rate limit: route orders-get, route orders-list
    Nothing limits how often these operations can be called, so one caller can use up the backend.
    Bind a rate-limit policy on the API (per consumer or per client address), or on the global level
    to cover every API.
- Traffic accepted without TLS: listener http
    These listeners accept plain HTTP on an address other machines can reach, so API keys, tokens
    and data cross the network readable. Give the listener a certificate (protocol: https with
    tls.certificates), or bind it to 127.0.0.1 behind a reverse proxy that terminates TLS.

Low
- The backend may hang requests: upstream orders
    These upstreams set the total timeout to 0 (unlimited), so a slow backend holds requests open
    for as long as it likes and the gateway's connections fill up. Set timeouts.total to what the
    slowest call needs, unless the backend streams (server-sent events) and must stay unlimited.

A rule looks at what an operation really runs, so a policy bound on the API, on a shared flow, on the environment or on the global level counts for every operation it reaches, and enabled: false on an operation takes it away again. The rules, by id:

Id Severity Fires when
no-authentication high An operation runs no api-key, jwt or basic policy
no-rate-limit medium An operation runs no rate-limit policy
jwt-without-audience medium A jwt binding lists no audiences
cors-wildcard-with-credentials medium A cors binding allows every origin and credentials
listener-without-tls medium A listener without TLS is bound to an address other machines can reach (loopback and h2c listeners are fine)
retry-on-unsafe-methods medium An upstream retries POST or PATCH
no-request-size-limit low An operation that takes a body runs no request-size-limit policy
headers-forwarded-unfiltered low An operation runs no forward policy, so every client header reaches the backend
backend-in-clear low A target uses http:// or grpc:// to a public address (private ranges, .internal, .local, .svc and names without a dot are fine)
no-health-check-with-several-targets low An upstream with several targets has active and passive health checks off
upstream-without-timeout low An upstream's total timeout is 0s (unlimited)

The command exits 0 when nothing is high, 1 when at least one high finding exists (so a pipeline can stop on it) and 2 when the file does not load; the load errors are printed as validate prints them. The same findings are at GET /api/v1/gateway/audit for the published revision (?draft=true for the draft) and in the Configuration section of the console's Needs-attention card.

Exit codes

0 success, 1 a request or validation failed (the error body is printed; for gateway audit, a high finding), 2 a usage error.