The API Gateway has a default mediation flow, which you can extend by adding custom mediation sequences. You create a custom mediation sequences either manually or using WSO2 tooling support (i.e., WSO2 Developer Studio), and then engage it per API or globally to all APIs of a specific tenant.
Creating per-API extensions
...
You can also engage mediation extension sequences to all APIs in the API Manager of a specific tenant at once. To do that, simply create the XML with the naming pattern WSO2AM--Ext--<DIRECTION>
and save it in the <APIM_HOME>/repository/deployment/server/synapse-configs/default/sequences
directory.