---
schema_version: "1"
id: f71726f935af63cff455ba100bb909d5435fc93199909d79d3e654ac169cf344
title: Applying Offline Custom Policies
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-gateway/policies-custom-offline-apply.md
canonical_url: https://docs.mulesoft.com/mule-gateway/policies-custom-offline-apply
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e3f51b0dd3fdd2b3e039efea920156912fd1fdb50afa0cafb156f8099e7a0278
description: MuleSoft Documentation Site
latest: true
---
---
product: Mule Gateway
---

# Applying Offline Custom Policies

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

An offline policy is applied directly to the runtime and not through API Manager. When you create a
file in the offline-policies directory, Mule runtime engine (Mule) detects the presence of the file
and starts applying the policy.

Mule then generates the JSON and XML policy files in a new directory in `%MULE_HOME%/policies`.

## Task Prerequisites

Before you apply an offline custom policy, ensure that:

- Mule runtime engine (Mule) is installed with
  [Mule Gateway capabilities](https://docs.mulesoft.com/mule-gateway/mule-gateway-capabilities-mule4) enabled.

- An [API](https://docs.mulesoft.com/api-manager/latest/api-instance-landing-page) configured with a basic endpoint or a
  proxy endpoint exists in API Manager.

- A Mule application is deployed with a
  [HTTP(s) based flow](https://docs.mulesoft.com/http-connector/1.10/http-listener-ref), which is linked to the API through
  Autodiscovery.

  When Autodiscovery is correctly configured in your Mule application, your application’s API is
  said to be tracked by or paired to API Manager.

## Apply an Offline Custom Policy

To apply an offline custom policy:

1.  If you do not want to use the policy template from Exchange due to various reasons, place the
    template JAR in the following directory before you apply the offline policy to the API.

    `%MULE_HOME%/policies/policy-templates`

2.  Create a JSON file in `%MULE_HOME%/policies/offline-policies` directory that defines the policy
    configuration.

3.  Name the JSON file after the policy ID.

4.  In the file, include the following configuration specifications:

    - Policy template information

      Specify the Exchange groupId, assetId, and version of the template used to deploy the offline
      policy definition.

    - IDs of the APIs that the policy will be applied to

    - A list of resources that the policy will be applied to

    - Order of the policy

    - Parameters if the defined template is using handlebars variables

      The following example shows a typical offline policy definition:

      { "template" : { "groupId" : "com.mulesoft.anypoint", "assetId" : "policyTemplate", "version"
      : "0.1.0" }, "api": \[ { "id": "1" }, { "id": "2" } \], "order": 1, "configuration" : {
      "payload" : "Payload" } }

5.  After you apply a custom offline policy, you must manually deploy it to a Mule runtime engine
    (Mule) file system.

## See Also

- [Removing Offline Custom Policies](https://docs.mulesoft.com/mule-gateway/policies-custom-offline-remove)
