Shared flows and flow hooks¶
How-to guideThe steps for one task.
Two ways to apply the same policies to many APIs, for two different needs.
| Shared flow | Flow hook | |
|---|---|---|
| What | A named, ordered bundle of policies | Shared flows attached at the environment level |
| Who | Any editor creates and attaches it | Administrators only |
| Where it runs | Where it is attached: on an API or an operation, before that level's own policies | On every API, before and after the whole chain |
| Can an API change it | Yes: override, merge, append or switch off individual policies | No: enforced, shown in violet with a lock in the API's flow |
| Use it for | "Standard security", "Public read-only", team conventions | Rules the organisation imposes: threat protection, CORS for the company domain, audit headers |
In one sentence: a shared flow is reused and may be adjusted; a flow hook enforces.
Creating a shared flow¶
Develop → Shared flows → New, from a starter (Standard security, Public read-only) or empty. Edit the policies with the same editor as everywhere else.
shared_flows:
- name: standard-security
description: What every partner-facing API runs
policies:
- type: threat-protection
- type: cors
config:
origins: [https://app.example.com]
- type: normalize-errors
Attach it on an API (Develop tab → Shared flows) or an operation:
apiVersion: apinx/v1
kind: API
name: orders
shared_flows: [standard-security] # attached flows, in order
policies:
- type: rate-limit # the API's own policies come after
config: { limit: 600, window: 1m }
Saving a change to a flow first shows the blast radius: every API and operation it reaches, with a confirmation. A flow in use cannot be deleted. Used by on the flow lists where it is attached.
Adjusting a flow's policy on one API¶
The flow's policies merge before the API's own, so the API may refine them:
policies:
- type: cors
strategy: merge # keep the flow's settings, add an origin
config:
origins: [https://partner.example]
- type: normalize-errors
enabled: false # off for this API only; the flow is unchanged
In the console, select the step in the API's Develop flow: its properties have an On / Off switch for this API and a Change for this API button. Off keeps the policy in the flow with its settings; nothing is removed. The same switch turns off a policy the API set itself, keeping its settings, so it can be turned back on later. An operation can turn back on what its API switched off: a binding with the policy's settings on the operation runs it there only.
Flow hooks¶
Develop → Policies → Flow hooks: attach shared flows on the client side (runs first) and the backend side (runs last), in order. Deploy the shared configuration.
Every API's Develop flow shows the hooked steps in violet with a Shared flow tag and a lock; the effective-policies view and the request inspector name the hook the step came from. Editors cannot change or switch them off, and a binding that tries is refused when saved with the way out: an administrator changes the flow, or the hooks. Making a hook change live (deploying the shared configuration, publishing, rolling back) is an administrator's act too.
A hooked authentication policy cannot be bypassed by adding another one on an API. Elsewhere, authentication policies bound together are alternatives; a hook's are alternatives among themselves only, and an API's own authentication is asked for as well, never instead (see Authentication).
Choosing between them¶
Ask "may an API opt out?" If yes, it is a shared flow. If a team switching it off would be an incident, it is a flow hook. For defaults every API should start from and may adjust without a flow, use the Global and Environment defaults on the same Policies page.