Contact Free trial Login

Migrating API Policies

In Mule 4, policies underwent major changes. A full explanation of them is available in Custom Policy General Reference (Nov 2017)

Defining Policy Behavior

In 3.x, the logic inside a particular policy is split in two blocks, one that is executed before the next policy or flow, the other executed after it.

Mule 3 Example
<?xml version="1.0" encoding="UTF-8"?>
<policy online="false"

        <mule:set-payload value="(pre)"/>

        <mule:set-payload value="(post)"/>

        <api-platform-gw:api-pointcut apiName="sampleApi" apiVersion="1.0.0"/>


In Mule 4, policies are no longer separated in a before and after block. They now work as a flow with an explicit jump to the next policy or flow that has to be defined in it.

Same behavior can be achieved in Mule 4 with the following config:

Mule 4 Example
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:xsi=""

    <http-policy:proxy name="policy-deployment">
        <http-policy:source propagateMessageTransformations="true">

            <set-payload value="(pre)"/>


            <set-payload value="(post)"/>


A few things to notice:

  • Logic is placed in the same block. Injecting behavior before the flow can be achieved just by putting logic before the execute-next element. To injecting behavior after the flow, you put logic after that element.

  • propagateMessageTransformations attribute in the http-policy:source element: Starting in Mule 4, changes to the Mule message (payload or attributes) before executing the flow are not propagated to it by default. To enable this, propagateMessageTransformations has to be set to true.

  • pointcut elements are no longer defined in the policy config file. Now, they are resolved by the API Gateway when policies are fetched from API Manager.

Endpoint and App pointcut elements are no longer available, and there is no replacement to them.

Uploading Policy Template to Exchange

In 3.x, once the policy is defined, the result is an XML file that has to be uploaded to API Manager.

In Mule 4, once the policy behavior is defined, the policy has to be packaged into a policy template JAR and uploaded to Exchange to make it available in API Manager.

  1. How to create a Maven project to generate the policy template JAR is explained in the Packaging a Custom Policy article.

  2. How to upload the JAR to Exchange is explained in the Uploading a Custom Policy to Exchange article.

Just like before, once the policy template JAR is in Exchange, it will appear in API Manager for APIs that belong to the same organization where the JAR was uploaded.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub