Plugin conditions let you attach an optional condition expression to any plugin.
When a request comes in, Kong Gateway evaluates the expression immediately before the plugin’s access phase.
If the expression evaluates to true, the plugin runs normally.
If it evaluates to false, the plugin is skipped for that request.
Conditions use Common Expression Language (CEL), a lightweight expression language.
Here are some common use cases for setting a condition on a plugin:
- Skip a global plugin for specific Routes, hosts, or request paths without removing the plugin or duplicating it across individual Routes.
- Enforce a plugin only for specific HTTP methods, headers, or query parameters.
- Make one plugin’s execution depend on context set by a higher-priority plugin.
- Condition plugin behavior on the authenticated Consumer, matched Route, or target Gateway Service.