Gateway configuration reference¶
ReferenceFacts to look up.
The apinx/v1 document format: every field of listeners, upstreams, APIs, operations,
policies, shared flows, products and flow hooks. This is the format the console exports, the
CLI imports, and revisions are stored in.
Apinx — Gateway Configuration Reference (apinx/v1)¶
Status: stable contract from G1-M3 (introduced in M2) · Applies to: gateway.yaml, the
CLI, the console's "View as code" panel and API Code tab, and export/import.
This document describes the declarative gateway configuration: what the proxy listens on, which backends it knows, and how requests are routed. It is the format G2 will continue to read unchanged (G1-SCOPE §4.3 rule 7).
Validate a file without starting the gateway:
Validation reports every problem at once, each naming the object, the field and the rule.
Document¶
apiVersion: apinx/v1
kind: Gateway
listeners: [...]
upstreams: [...]
apis: [...] # optional management grouping (see below)
shared_flows: [...] # optional reusable policy bundles (G1-M8; ADR-0015)
products: [...] # optional products with plans, offered to consumers (G1-M9)
routes: [...]
| Field | Rule |
|---|---|
apiVersion |
Must be apinx/v1 |
kind |
Must be Gateway |
listeners |
At least one |
upstreams |
Zero or more; every route must reference one, unless a policy answers the route itself (see Routes) |
apis |
Zero or more; management metadata the proxy ignores |
shared_flows |
Zero or more named policy bundles; management metadata the proxy ignores. policy_sets is still accepted as a legacy alias; exports write shared_flows |
products |
Zero or more products with their plans; the control plane binds the subscription policy on their APIs' routes |
routes |
Zero or more, fully resolved (full path, upstream, policies) |
Environment variables¶
A file may reference environment variables; they are substituted when the file is read, before parsing:
| Form | Meaning |
|---|---|
${NAME} |
The variable's value; unset, and without a default, the file is rejected (APX-GW-0012, every missing name in the details) |
${NAME:-default} |
The value, or default when the variable is unset or empty (shell semantics); the default may hold : and / |
$${ |
A literal ${ |
Names are upper case: letters, digits and underscores, not starting with a digit
([A-Z_][A-Z0-9_]*). Lower-case references (${client_ip}, ${host}, ${principal.name},
${secret.<name>}, ${header.<Name>}, …) are the per-request templates policies evaluate and
pass through untouched. Comments are left as written: a reference in a comment is neither
required nor replaced. A # inside a quoted value or a block scalar (|, >) is part of the
value, not a comment, and references there are replaced.
Expansion applies wherever a file is read: apinx gateway run (file mode), apinx gateway
validate, apinxctl validate <file> and the seed of an empty store. A document the console
holds, exports or stores as a revision is never expanded: a revision is what was applied, not
a template. See the guide Run from a file, no database.
APIs (management grouping)¶
The console groups routes under APIs. In the YAML this is carried by an optional apis
list and an api annotation on routes, so an export keeps its structure when imported
again. The proxy routes on the resolved route fields alone.
apis:
- name: orders
description: Order management
hosts: ["*"]
base_path: /orders
upstream: orders-svc # default for the API's routes
strip_prefix: true
policies: [] # applied before each route's own policies
shared_flows: [standard-security] # optional: flows merged before the API's own policies
enabled: true # false leaves the API's routes out of the gateway
routes:
- name: orders-list # <api>-<route>
api: orders
path: /orders # base_path joined with the route's sub-path
upstream: orders-svc
strip_prefix: true
On import, a route with an api annotation is attached to that API with the base path
removed from its path; a route without one becomes an API of its own so nothing is lost.
API definition (kind: API)¶
The console's API workspace has a Code tab that shows and edits one API as its owner
writes it: the API's settings, its attached shared flows and own policies, and its
operations (routes) with their own policies, not the resolved export. It is read with
GET /api/v1/apis/{id}/definition, checked without saving with
POST /api/v1/apis/{id}/definition/check, and saved with PUT /api/v1/apis/{id}/definition.
apiVersion: apinx/v1
kind: API
name: orders
base_path: /orders
upstream: orders-backend
strip_prefix: true
shared_flows: [standard-security]
policies:
- type: api-key
operations:
- name: list
path: /
methods: [GET]
policies: []
Unknown keys are refused. Saving validates the API and every operation first and writes nothing if anything is invalid; operations are matched by name, and one left out is deleted.
Names (name on listeners, upstreams and routes) are lowercase letters, digits and hyphens,
1 to 63 characters, unique within their kind. Durations take a unit: 30s, 5m, 1h.
Where "unlimited" is allowed it is written 0s.
Listeners¶
A listener is a server socket.
listeners:
- name: http
address: ":8080" # host:port or :port
protocol: http # http (default) | https
h2c: true # HTTP/2 over cleartext on an http listener
limits:
max_connections: 0 # 0 = 10000 (the default), -1 = unlimited
read_header_timeout: 10s
idle_timeout: 60s
max_header_bytes: 1048576 # at least 4096
max_concurrent_streams: 250 # HTTP/2 streams open per connection
- name: https
address: ":8443"
protocol: https
tls:
certificates: # at least one; SNI selects by the certificate's names
- cert_file: certs/api.crt
key_file: certs/api.key
client_auth: none # none | request (capture if offered) | require (verify)
client_ca_file: certs/clients-ca.pem # required for `require`; enables verification for `request`
min_version: "1.2" # "1.2" (default) | "1.3"
HTTPS listeners negotiate HTTP/2 through ALPN; h2c applies to http listeners only. A
gRPC client needs one or the other (ADR-0028). A client certificate, when presented, is
available to policies (M4).
Upstreams¶
An upstream is a logical backend: targets plus how to reach them.
upstreams:
- name: orders
balancer: round_robin # round_robin | weighted | least_connections | consistent_hash
hash: # consistent_hash only
source: header # header | cookie | ip
key: X-User-ID # header or cookie name
targets:
- url: http://10.0.0.5:8080 # http, https, grpc (HTTP/2 without TLS) or grpcs; host:port[/base-path]; no query or credentials
weight: 1 # weighted balancer; default 1
pass_host_header: false # forward the client's Host instead of the target's
max_idle_conns_per_target: 256
health:
active:
enabled: false
interval: 5s
timeout: 2s # must be shorter than interval
path: / # a grpc:// or grpcs:// target is asked grpc.health.v1.Health/Check instead
expected_statuses: [] # empty = 200..399; not for gRPC targets (SERVING is healthy)
healthy_threshold: 2 # consecutive successes to re-admit
unhealthy_threshold: 3 # consecutive failures to eject
passive:
enabled: false
failures: 5 # consecutive failed requests to eject
eject_for: 30s
circuit_breaker:
enabled: false
failure_threshold: 5 # consecutive failures to open
open_duration: 30s
half_open_requests: 1 # probes allowed while half open
retry:
attempts: 0 # additional attempts (0 = off, max 10)
conditions: [connect_error, reset, "503"]
methods: [GET, HEAD, OPTIONS, TRACE, PUT, DELETE]
backoff: 25ms # exponential with full jitter
max_backoff: 250ms
budget_ratio: 0.2 # retries ≤ 20% of recent requests
max_body_bytes: 65536 # larger bodies are sent once, never retried
timeouts:
connect: 5s
tls_handshake: 5s
response_header: 30s
total: 60s # 0s = unlimited (needed for SSE and long polls)
idle: 90s # idle keep-alive connections
tls: # for https targets
server_name: ""
ca: "" # PEM text of a private CA (the only form Apinx Cloud accepts)
ca_file: "" # or its file; ca and ca_file are alternatives
insecure_skip_verify: false # refused on a new upstream in Apinx Cloud
client_cert_file: ""
client_key_file: ""
Retry conditions: connect_error, reset, timeout, 5xx, 502, 503, 504,
retriable_4xx (408 and 429). Transport errors and 502/503/504 responses count as target
failures for passive health and the breaker; other statuses are application responses and
do not.
A target URL may carry a base path (http://host:8080/api), which is prepended to the
forwarded path.
Routes¶
A route matches requests and sends them to an upstream.
routes:
- name: orders-v1
hosts: ["api.example.com", "*.example.com"] # exact, *.suffix, or "*" (default)
path: /v1/orders/{id} # see patterns below
methods: [GET, PUT] # empty = any
headers:
- { name: X-Canary, value: "yes" } # exactly one of value | regex | present
- { name: X-Trace, present: true }
listeners: [https] # empty = all listeners
upstream: orders
strip_prefix: false # remove the literal prefix before forwarding
priority: 0 # breaks ties; higher wins
timeouts:
total: 0s # overrides the upstream's total
websocket:
enabled: false
idle_timeout: 60s
max_duration: 0s # 0s = unlimited
mirror: # optional: copy a share of the requests elsewhere
upstream: orders-next # must exist; may be the route's own
percent: 100
max_body_bytes: 65536
timeout: 0s # 0s = the mirror upstream's total timeout
backend_credentials: false # true sends the token upstream-auth fetched for the backend with the copy
canary: # optional: serve a share of the requests from another upstream
upstream: orders-next # must exist and differ from the route's own
percent: 10 # 1 to 100
pin_header: X-Apinx-Canary # optional: "canary" or "stable" in it picks the side
policies:
- type: set-header
config:
request: { X-Gateway: apinx }
response: { X-Served-By: apinx }
upstream may be omitted when a policy answers every request of the route itself: a
mock-response, or a service-callout with respond. Validation refuses a route with
neither (must name an upstream, unless a mock-response policy or a service-callout with
respond answers the route); a request that reaches the end of such a chain unanswered gets
502 APX-RT-0010.
mirror¶
Copies a share of the route's requests to a second upstream on a detached context, after the
policies ran and the real dispatch started; the answers are discarded. The copy carries
X-Apinx-Mirror: 1 and Via: 1.1 apinx. At most 64 copies per route are in flight; beyond
that a copy is dropped, never queued. Prometheus counts apinx_proxy_mirrored_total{route,
outcome}; the trace records a mirror step with the decision.
| Field | Default | Rule |
|---|---|---|
upstream |
required | An upstream of the document; may be the route's own |
percent |
100 |
Share of requests copied, 1 to 100 |
max_body_bytes |
65536 (64 KiB) |
A request with a larger body is not copied; at most 8 MiB |
timeout |
the mirror upstream's timeouts.total (30s when that is unlimited) |
Bounds one copy; not negative |
backend_credentials |
false |
The copy leaves without the token upstream-auth fetched for the route's backend; true sends it, for a mirror that is a second copy of the same backend |
canary¶
Serves a share of the route's requests from a second upstream and the rest from the route's own
(ADR-0048), chosen per request after the policies ran. A request whose pin_header says
canary or stable goes to that side whatever the share. When no target of the canary upstream
is in rotation, the stable side serves everything. The chosen upstream is the one the trace, the
access log and the span name; a canary answer carries X-Apinx-Canary: 1. Prometheus counts
apinx_proxy_canary_total{route, side, reason} (side stable or canary; reason sampled,
pinned or unavailable); the trace records a canary step with the same words. In Apinx Cloud
the plan must include canaries (APX-SAAS-0066).
| Field | Default | Rule |
|---|---|---|
upstream |
required | An upstream of the document, not the route's own; the route needs its own upstream |
percent |
required | Share of requests served by the canary, 1 to 100 |
pin_header |
none | A header name (letters, digits and hyphens, up to 64); empty for no pinning |
Path patterns¶
| Pattern | Matches | Notes |
|---|---|---|
/orders |
exactly /orders |
trailing slash is significant: /orders/ is a different pattern |
/orders/{id} |
one segment | {id} is captured as a parameter |
/files/{rest...} |
zero or more segments | must be the last segment; captures the remainder including slashes |
/ |
the root only |
Precedence at each segment: literal, then {param}, then {rest...}. Among routes with the
same path, the one with more predicates (methods, headers, listeners) wins, then higher
priority, then definition order. Host precedence: exact host, then the longest matching
*.suffix, then *.
If a path matches but no route allows the method, the response is 405 with an Allow
header (APX-RT-0002). Paths containing . or .. segments, empty segments or
percent-encoded slashes are rejected with 400 APX-RT-0003 before routing.
strip_prefix¶
Removes the literal leading part of the pattern. With path: /demo/{rest...} and
strip_prefix: true, a request for /demo/echo is forwarded as /echo.
Policies¶
Every policy type, its settings and defaults are in POLICIES.md, generated from the code. A binding names a type and its configuration:
policies:
- type: api-key
- type: rate-limit
config: { limit: 100, window: 1m, key: consumer }
- type: transform
config:
request: { headers: { set: { X-Caller: "${principal.name}" } } }
Policies run in phase order on the request (access → protection → authentication →
traffic → caching → errors → transformation), whatever order they are written in, and in
reverse on the response, so transform reshapes the backend's answer first,
normalize-errors then shapes the body for the resulting status, and cache stores what
the client receives. A rejecting policy stops the chain; nothing reaches the upstream.
Policies that hold a per-request resource are always released when the response completes.
transform also reshapes JSON bodies and the response status with jq programs
(ADR-0011): request.body.program, response.body.program, response.status.set|map|when.
Bodies are buffered only on routes that bind a body program, up to max_bytes (default
1 MB) and within time_budget (default 50 ms); a body over the limit or a failing program
never forwards a partial result. The console previews a binding against a sample before it
is published. Settings in POLICIES.md.
policies:
- type: transform
config:
request:
body: { program: "{customer_id: .body.customerId, items: [.body.lines[] | {sku, qty: .quantity}]}" }
response:
body: { program: "{id: .body.orderId, total: ([.body.lines[].price] | add)}" }
status:
when: [{ if: ".body.ok == false", status: 400 }]
map: { "502": 503 }
Binding levels and merge¶
Bindings live at four levels, widest first: global (top-level policies:),
environment (environment.policies), API (apis[].policies) and route
(routes[].policies). For an API in a product with a plan, the control plane adds a
product level between the environment and the API (see below). A route runs the merge of
every level on its path (FR-4.13, ADR-0012, ADR-0015), so the path is always single. A binding
at a narrower level combines with the same policy type inherited from a wider one according to
its strategy:
strategy |
Effect |
|---|---|
override (default) |
replaces the inherited settings entirely |
merge |
changes only the settings given; the rest stay inherited |
append |
runs in addition to the inherited instance |
enabled: false switches an inherited policy off at that level (a public route inside a
key-protected API). name distinguishes two bindings of one type (two rate limits with
different keys). The console shows the effective policies of every route with where
each entry came from; GET /api/v1/routes/{id}/effective-policies returns the same, and
/apis/{id}/… gives what an API hands down.
scope says how wide a rate-limit or concurrency-limit counts: route (the default,
also written as an empty value) counts the route alone, api shares one counter across every
route of the route's API, and environment shares one across every route of the gateway.
The control plane sets it from the level a binding was bound at, so a limit on an API counts
the whole API and a route's own binding counts that route alone; in a hand-written
apinx/v1 file write scope: api on each route of the API that shares the counter. The
data plane builds one policy instance per scope and the routes in it share it, so the rule
holds on one instance and, through Redis, across instances. Policies without per-caller
state ignore the field.
Shared flows¶
A shared flow is a named bundle of bindings written once and attached by name to an API
or a route through shared_flows:. At each attachment point the attached flows expand in
place, in list order, before the level's own bindings. The level's own binding of the same
policy therefore wins over its flow. Strategies inside a flow act on what the attachment point
inherits, exactly as if the bindings were written there.
shared_flows:
- name: standard-security
description: Key authentication and a fair-use limit
policies:
- type: api-key
- type: rate-limit
config: { limit: 100, window: 1m, key: consumer }
apis:
- name: cards
shared_flows: [standard-security]
policies:
- type: rate-limit # overrides the flow's limit for this API only
config: { limit: 10, window: 1m }
routes:
- name: cards-refund
api: cards
shared_flows: [audit-headers] # attachments on the route itself, as metadata
policies: [...] # resolved chain, as always
Rules, all checked when the draft is saved or imported, each naming the field it concerns:
| Rule | Consequence |
|---|---|
every shared_flows entry must name a flow, once per list |
otherwise unknown shared flow "x" or attached twice on shared_flows[i] |
| flows do not nest | a flow has policies, never shared_flows |
| a flow already applied higher on the path | is not applied again further down; the console flags it |
| deleting a flow that is attached anywhere | is refused with 409 APX-CP-0013, naming its users |
| renaming a flow | rewrites every reference in the same transaction |
policy_sets (the name before ADR-0015) is still accepted as a legacy alias for
shared_flows, both for the top-level list and for the attachments on APIs and routes;
exports write shared_flows only. Unknown keys are still refused.
API groups were removed (ADR-0015). A document that still has a top-level groups: list
or an API group: field is converted on import with identical behaviour: the group's own
policies become a shared flow named after the group (or <group>-group if that name is
taken, with a description naming the former group and its owner), and every member API gets
the group's shared flows followed by that new flow, attached ahead of its own shared flows.
The same conversion runs once at start-up on the draft and every stored revision (audited as
action migrate on object group). In the Admin API, an API that names group is refused
with "API groups were removed; attach shared flows to the API instead".
Order of the full merge path for one route:
(The product level exists only for APIs in a product; see below. Environment flow hooks are not a merge level: they surround the merged chain, see below.)
In the YAML, routes always carry their resolved chain (the proxy reads nothing else),
while policies:, environment.policies, shared_flows, apis[].policies and
routes[].shared_flows are management metadata that let the console keep the levels through
export and import. On import, each route's own bindings are recovered from the difference
between its resolved chain and what it inherits, including its own attached flows. Documents
written before G1-M8 have none of these fields and import unchanged.
API versions and lifecycle¶
Each version of an API is its own API with its own base path, grouped by family and
labelled by version, with a lifecycle state (ADR-0018):
apis:
- name: orders
family: orders
version: v1
base_path: /orders/v1
lifecycle:
state: deprecated # created | published (default) | deprecated | retired
since: 2026-09-25T09:00:00Z # set by the control plane
sunset: 2027-01-31T00:00:00Z
successor: orders-v2
note: Move to v2 by 31 January.
- name: orders-v2
family: orders
version: v2
base_path: /orders/v2
A version can instead share its base path and be chosen by a header:
- name: orders-v2
family: orders
version: v2
base_path: /orders/v1 # the same base path as v1
version_selector: {header: Api-Version, value: v2}
Requests with Api-Version: v2 reach it; requests without it reach the version that has no
selector. A created version is not served. A deprecated one is served with Deprecation,
Sunset and Link: </orders/v2>; rel="successor-version" on its answers. A retired one
answers 410 Gone (APX-PL-0024) before any other policy. The compiler binds the managed
lifecycle policy for the last two; published versions carry nothing.
Environment flow hooks¶
A flow hook attaches shared flows to every route of the environment at a fixed place around each API's own policies (ADR-0017). They are the company-wide rules: no API or operation can override them, merge into them or switch them off, and only administrators change them or the shared flows they attach.
environment:
flow_hooks:
client: [company-edge] # first on every request, last on every response
backend: [internal-auth] # last before the backend, first on its answer
| Hook | Request | Response |
|---|---|---|
client |
runs first, before the API's policies | runs last, just before the client |
backend |
runs last, just before the backend | runs first, on the backend's answer |
Each hook runs its flows in the order listed and each flow's policies in phase order. A flow
may be hooked once, on one side. An API or route that also attaches a hooked flow does not run
it a second time. In the compiled document every hooked binding is written into each route's
chain with hook and flow set, and the proxy keeps them at their place whatever their phase:
routes:
- name: orders-list
policies:
- {type: threat-protection, hook: client, flow: company-edge}
- {type: api-key}
- {type: set-header, name: internal, hook: backend, flow: internal-auth, config: {...}}
On import the hooked bindings go back to the hooks, not to the routes. Hooks are part of the environment configuration: they are revised and deployed with it (ADR-0016). Cost: none per request beyond the hooked policies themselves; ordering is decided when a configuration is applied.
Products and plans¶
A product is what you offer to consumers: a set of APIs and one or more plans. An
application subscribes to a product at a plan, and the plan's rate limit and quota then apply
to every call it makes to any of the product's APIs (ADR-0013). Products and plans are
configuration, like everything in this file. Subscriptions are not: they belong to the
consumers, change at once without a publish, and are managed in the console, the Admin API
(/api/v1/applications/{id}/subscriptions, /api/v1/subscriptions) or apinxctl.
products:
- name: payments
display_name: Payments for partners
description: Card and wallet APIs for resellers
apis: [cards, wallets]
plans:
- name: free
display_name: Free
quota: { limit: 1000, period: day } # day or month, reset at 00:00 UTC / the 1st
rate_limit: { limit: 5, per: second } # second, minute or hour
- name: gold
display_name: Gold
quota: { limit: 1000000, period: month }
rate_limit: { limit: 100, per: second }
approval_required: true # new subscriptions wait for approval
- name: legacy
state: retired # existing subscribers keep it; nobody new
- name: lookup
display_name: Lookups
apis: [aqdak]
operations: # offer only these operations of aqdak (ADR-0036)
aqdak: [get-cities, get-countries]
plans:
- name: basic
quota: { limit: 10000, period: day }
operations narrows an API of apis to the operations named, by their name in the API; an API
without an entry is offered whole. Once any product offers an API, whole or in part, an
operation of it that no product offers is closed: every call gets 403 APX-PL-0015 with the
operation named, until a product offers it or the operation switches subscription off to be
public.
| Rule | Consequence |
|---|---|
apis must name APIs in the document |
otherwise unknown api "x" on products[].apis[i] |
operations keys must be among the product's apis; names once each |
the field operations[api] is named in the error; in the console also an operation the API does not have, or an empty list |
plan names unique within the product; limits at least 1; per and period from the lists above |
the field is named in the error |
| the routes of an API in a product must require an API key | a plan is chosen by the calling application, and only api-key identifies one; switch subscription off on a route to make it public |
| an API can be in several products | but an application holds at most one live subscription that offers a given operation (409 APX-CP-0019): products offering different operations of one API do not conflict |
| an operation a product names | cannot be deleted, or removed in the API's Code tab, until the product no longer names it; a rename follows |
| a plan with live subscriptions | cannot be removed or renamed; retire it |
| a product with live subscriptions | cannot be deleted (409 APX-CP-0013) |
A product without plans offers nothing yet and changes nothing: its APIs keep working as before, and no API key is required, until the first plan is added and published.
When compiling, the control plane inserts a product level between the environment and the API
of every API in a product that has at least one plan. On each route it carries one subscription binding with the plans of the
products that offer that operation (none for a closed one), so the effective view reads "From product payments" and an API or a route can switch
it off like any inherited policy:
At run time the subscription policy (phase 400, after authentication) finds the caller's
subscription and applies the plan: 403 APX-PL-0015 without a subscription, 403 APX-PL-0016
while pending or suspended, 429 APX-PL-0007 over the rate limit and 429 APX-PL-0017 when
the quota is used up. Responses carry RateLimit-*, X-Quota-Limit, X-Quota-Remaining
and X-Quota-Reset. Quota counters are kept per subscription, flushed to the store every 10
seconds and on shutdown, and restored on start.
Consumers¶
api-key looks keys up in the Consumers directory (applications and their keys, managed
in the console or under /api/v1/applications). Keys are not part of the gateway document:
issuing, rotating or revoking one takes effect on the next request without a publish.
Authenticating to a backend (upstream-auth)¶
Some backends want a token of their own, issued by their identity provider, not the caller's. The typical case: a mobile app signs in with your provider (XXAuth) and gets a JWT; the employees API belongs to a partner (YYAPI) that only accepts tokens from its provider (YYAuth), and the app must never hold YY credentials. The gateway does the handshake:
apiVersion: apinx/v1
kind: API
name: employees
base_path: /yy
upstream: yy-api
strip_prefix: true
policies:
# 1. The caller's token, validated against your provider's published keys.
- type: jwt
config:
issuer: https://xxauth.example.com/
jwks_url: https://xxauth.example.com/.well-known/jwks.json
audiences: [mobile-xx]
required_claims:
employee_id: [] # present, any value
strip: true # the XX token never reaches the partner
# 2. The gateway's own token for the partner, fetched with client
# credentials only the gateway holds, cached until shortly before expiry.
- type: upstream-auth
config:
token_url: https://yyauth.example.com/oauth/token
client_id: gateway-xx
client_secret: ${secret} # stored encrypted (ADR-0014)
scopes: [employees:read]
headers:
X-User-Id: ${claim.employee_id} # whichever claim carries the user
X-Dept: ${claim.profile.dept} # dotted path for nested claims
operations:
- name: all
path: /{rest...}
What happens per request: jwt verifies the XX token (keys cached, no call to XXAuth);
upstream-auth sets Authorization: Bearer <yy-token> from its cache, calling YYAuth only when
the token is missing or within refresh_before of expiry (one call per burst, other requests
wait for it), and adds the extra headers from the caller's claims. A header whose claim is
missing on a request is left out. A 401 from the partner discards the cached token so the next
request fetches a fresh one. If YYAuth is down and no valid token is cached, the request is
refused with 502 APX-PL-0026; a still-valid token keeps serving through a YYAuth outage.
Grants: client_credentials (default) or password (a service account's username and
password with the client credentials). Client credentials go as HTTP Basic by default, or as
form fields with client_auth: body. Extra token-endpoint parameters (audience, params)
cover Auth0 and Keycloak variants. Ten routes to the same partner share one token: the cache is
keyed by endpoint, client and scopes, and survives redeploys.
A SOAP backend as a JSON operation (soap)¶
A SOAP service is published as JSON operations: one soap policy per operation, bound on the
route only (an API, shared-flow, environment or global binding is refused at validation). The
consumer sends a JSON object; the gateway renders request into the envelope, posts it to the
backend and answers the decoded JSON, or a coded error for a fault. The guide is
SOAP backends as JSON APIs; the settings are in
POLICIES.md.
routes:
- name: orders-get
path: /orders/get
methods: [POST]
upstream: orders-soap # targets: http://orders.internal:8080
policies:
- type: soap
config:
version: "1.1" # 1.1: text/xml + SOAPAction; 1.2: application/soap+xml; action=...
action: urn:example:orders/GetOrder
endpoint_path: /soap/orders # the path the envelope is posted to, for every operation
namespaces: # declared on the Envelope for the template's prefixes
ord: urn:example:orders
request: | # the operation element; every value XML-escaped
<ord:GetOrder>
<ord:OrderId>${body.orderId}</ord:OrderId>
</ord:GetOrder>
headers: "" # extra SOAP header elements, references allowed
security: username_token # none (default) or username_token
username: svc-gateway # references allowed
password: env:ORDERS_SOAP_PASSWORD # secret: sealed; env:, file: or vault: reference
password_type: digest # text (PasswordText) or digest (PasswordDigest + Nonce + Created)
timestamp: false # wsu:Created on a text token
response:
unwrap: GetOrderResponse/Order # path under the Body; default: the Body's first child
arrays: [Line] # always arrays, even with one element
attributes: drop # or keep, as @name keys
types: string # or infer (numbers and booleans typed)
jq: "" # optional jq on the converted JSON
limits: { depth: 32, elements: 100000, text: 1MB } # DTDs always refused
max_body: 1MB # consumer body and envelope; over it 413 APX-SOAP-0005
max_response: 4MB # backend answer; over it 502 APX-SOAP-0004
| Setting | Default | Meaning |
|---|---|---|
version |
1.1 |
Envelope namespace and media type; 1.1 sends SOAPAction: "<action>" (empty when unset), 1.2 the action parameter of application/soap+xml and no header. |
action |
A URI without quotes or spaces. | |
namespaces |
Prefix → URI on the Envelope. soap/env (the envelope's own), wsse and wsu with a token, and xml… are reserved. |
|
request |
required | The operation element with ${body.<field>}, ${path.<param>}, ${query.<name>}, ${header.<Name>}, ${claim.<name>}, ${callout.<name>.body.<field>} references, ${each body.<list> as <var>}…${end} for arrays (one level of nesting) and ${if <ref>}…${end} for optional elements. Compiled at load; a template that is not well-formed with its references filled is refused naming the line (APX-SOAP-0006). |
headers |
Extra SOAP header elements, same syntax. | |
security, username, password, password_type, timestamp |
none, , , text, false |
WS-Security UsernameToken. username and password are required with username_token; password is a secret field like upstream-auth's. HTTP-level credentials stay with upstream-auth. |
response.unwrap |
the Body's first child | Element path whose content is the JSON (GetOrderResponse/Order). |
response.arrays |
Element names decoded as arrays even when single. | |
response.attributes |
drop |
keep: attributes as @name; a text element with attributes gets #text. |
response.types |
string |
infer: true/false and JSON-shaped numbers typed; everything else stays a string. |
response.jq |
jq on the converted value; its single output is the body; the transform time budget applies. | |
response.limits.depth, .elements, .text |
32, 100000, 1MB | XML limits on the backend answer before decoding; DTDs and entities always refused. |
max_body, max_response |
1MB, 4MB | Largest consumer body or envelope (413 APX-SOAP-0005), largest answer (502 APX-SOAP-0004). |
endpoint_path |
Absolute path on the backend, no query; replaces the request's path. Empty keeps it. |
Conversion rules: namespaces dropped and case kept; text elements as strings; children as
objects; repeated siblings and the names in arrays as arrays; xsi:nil as null; an empty
element as ""; attributes dropped unless kept. A Client/Sender fault answers
400 APX-SOAP-0002 with the fault's code, string and detail in the error's details (verbose
errors) and in the inspector; any other fault 502 APX-SOAP-0003. The policy runs after
transform and service-callout on the request and before them on the response, so both see
JSON. ${ENV} substitution and secret references work as in every policy; ${body.x} is not an
environment reference (those are upper case).
Errors the proxy returns¶
Every rejection carries X-Apinx-Error and a application/problem+json body with the
same code. With console.errors.verbose: true the body includes remediation text.
| Code | Status | Meaning |
|---|---|---|
APX-RT-0001 |
404 | No route matches |
APX-RT-0002 |
405 | Route matched, method not allowed (Allow lists methods) |
APX-RT-0003 |
400 | Malformed path |
APX-RT-0004 |
400 | WebSocket upgrade on a route without websocket.enabled |
APX-RT-0005 |
502 | Backend did not complete the WebSocket handshake |
APX-RT-0006 |
505 | WebSocket attempted over HTTP/2 |
APX-RT-0008 |
429 | More WebSocket sessions open than the gateway allows (an organization's plan in Apinx Cloud) |
APX-RT-0010 |
502 | The route has no upstream and no policy answered the request |
APX-UP-0001 |
503 | No healthy target |
APX-UP-0002 |
503 | Every target's circuit breaker is open |
APX-UP-0003 |
502 | Backend unreachable |
APX-UP-0004 |
504 | Backend did not start responding in timeouts.response_header |
APX-UP-0005 |
504 | Exchange exceeded timeouts.total |
APX-UP-0006 |
502 | Backend returned an invalid response |
APX-UP-0007 |
503 | Backend failed and the retry budget is exhausted |
APX-PL-0001 |
401 | No credentials presented (api-key, jwt, basic) |
APX-PL-0002 |
401 | Credentials invalid, expired or revoked |
APX-PL-0003 |
403 | Authenticated but missing a scope, claim or application allow-list entry |
APX-PL-0004 |
403 | Address blocked by ip-filter |
APX-PL-0005 |
405 | Method blocked by allow-methods |
APX-PL-0006 |
413 | Body larger than request-size-limit |
APX-PL-0007 |
429 | rate-limit reached (Retry-After, RateLimit-* headers) |
APX-PL-0008 |
503 | concurrency-limit reached |
APX-PL-0009 |
503 | jwt could not fetch the signing keys (fail closed) |
APX-PL-0010 |
403 | Origin rejected by cors |
APX-PL-0011 |
backend's | Backend error body replaced by normalize-errors |
APX-PL-0012 |
400 | Request body is not JSON on a route whose transform requires JSON (if_not_json: reject) |
APX-PL-0013 |
500 | The transform request body program failed or exceeded its budget; nothing was forwarded |
APX-PL-0014 |
502 | The backend's response could not be transformed (program failed, body too large, not JSON, unsupported encoding); the client got this error instead of a partial body |
APX-SOAP-0001 |
400 | The body of a soap operation is not a JSON object |
APX-SOAP-0002 |
400 | The SOAP backend answered a Client/Sender fault (details carry the fault) |
APX-SOAP-0003 |
502 | The SOAP backend answered a Server/Receiver or other fault |
APX-SOAP-0004 |
502 | The SOAP backend's answer is not an envelope the gateway can convert, is over max_response or breaks an XML limit (a DTD is always refused) |
APX-SOAP-0005 |
413 | The body of a soap operation, or the envelope built from it, is over max_body |
Configuration errors (APX-GW-0001 to 0006) are reported by apinx gateway validate
and in the log when a reload is rejected; the running configuration is never replaced by
an invalid one. The console's Error reference page (/errors) and
GET /api/v1/errors list every code with its remediation.
Applying changes¶
From M3 the embedded control plane owns the configuration. Changes made in the console,
through the Admin API or with apinxctl accumulate in a draft; publishing compiles
the draft into an immutable revision and swaps it in atomically: requests in flight
finish on the old configuration, new requests use the new one, and no request is
dropped. Health and breaker state of unchanged targets is carried over. Listeners are
added, removed or restarted only when their own definition changes. Rolling back to a
prior revision is the same swap in the other direction.
The file named by proxy.config_file (or ./gateway.yaml) seeds an empty store on
first start and is published as revision 1. Afterwards use apinxctl import or the
console's Import panel to load a file into the draft, then publish.
In file mode (apinx gateway run [file]) there is no store: the file is the
configuration, polled every two seconds and applied with the same atomic swap when it
changes; a file that fails to load is logged and the previous configuration keeps serving.