---
schema_version: "1"
id: febbaabced7fd65b4bb657ab8d63de89c94a5688dbab97f6bfd1c51866318d94
title: Custom Policy Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/pdk/1.4/policies-pdk-policy-templates.md
canonical_url: https://docs.mulesoft.com/pdk/1.4/policies-pdk-policy-templates
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a1cb00649e2238808baf6710226faff82d8a963796cc1ac8dd22d3e487e31f06
description: MuleSoft Documentation Site
release: "1.4"
latest: false
---
---
product: Omni Gateway Policy Development Kit (PDK)
version: 1.4
---

# Custom Policy Examples

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

Flex Gateway Policy Development Kit (PDK) provides example policy projects to help you start
configuring your Rust source code.

You can find all example policies and their documentation in the
[PDK Custom Policy GitHub Repository](https://github.com/mulesoft/pdk-custom-policy-examples).

## API Policy Examples

PDK includes the following API example policies:

- [Block Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/block/README.md):
  Use the Block Policy as an example of how to block IP ranges by implementing
  [periodic functions](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-timer) and
  [HTTP calls](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-http-request).

- [Certification Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/certs/README.md):
  Use the Certification Policy as an example of how to obtain data concerning connection
  certificates.

- [CORS Validation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/cors-validation/README.md):
  Use the CORS Validation Policy as an example of how to use functions of the
  [CORS Library](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-cors) in your custom policy.

- [Crypto Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/crypto/README.md):
  Use the Crypto Policy as an example of how to use
  [third-party libraries](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-libraries) that provide cryptography
  capabilities in your custom policy.

- [Data Caching Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/data-caching/README.md):
  Use the Data Caching Policy as an example of how to implement
  [data caching](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-caching) in your custom policy.

- [DataWeave Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/dataweave/README.md):
  Use the DataWeave Policy as an example of how to handle
  [custom DataWeave expressions](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-dataweave) in your custom policy.

- [JWT Validation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/jwt-validation/README.md):
  Use the JWT Validation Policy as an example of how to use functions of the
  [JWT Library](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-jwt) in your custom policy.

- [Metrics Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/metrics/README.md):
  Use the Metrics Policy as an example of how to periodically send data to a metric ingestion
  service by implementing [periodic functions](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-timer) and
  [HTTP calls](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-http-request).

- [Query Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/query/README.md):
  Use the Query Policy as an example of how to handle query parameters in your custom policy.

- [Simple OAuth 2.0 Validation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/simple-oauth-2-validation/README.md):
  Use the Simple OAuth 2.0 Validation Policy as an example of how to implement
  [HTTP calls](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-http-request) in your custom policy.

- [Spike Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/spike/README.md):
  Use the Spike Policy as an example of how to configure worker spike control by implementing
  [periodic functions](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-timer).

- [Stream Payload Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/stream-payload/README.md):
  Use the Stream Payload Policy as an example of how to
  [read payload bodies larger than 1MB](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features-headers#streaming-bodies).

- [TLS Calls Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/tls-calls/README.md):
  Use the TLS Calls Policy as an example of how to make HTTPS calls in your policy without
  installing certificates on the operating system running Flex Gateway.

## A2A and MCP Server Policy Examples

PDK includes the following A2A and MCP example policies:

- [A2A Support Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/main/agent-policies/a2a-support-policy/README.md):
  Demonstrates how to add A2A support.

- [MCP Support Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/main/agent-policies/mcp-support-policy/README.md):
  Shows how to add MCP support.

- [A2A PII Detector Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/main/agent-policies/a2a-pii-detector-policy/README.md):
  Demonstrates how to log or block sensitive information in A2A agent interactions.

- [A2A Prompt Decorator Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/main/agent-policies/a2a-prompt-decorator-policy/README.md):
  Shows how to modify prompts sent to an A2A agent.

## Set Up an Example Policy Project

To use an example policy project:

1.  Make sure you have installed all [PDK prerequisites](https://docs.mulesoft.com/pdk/1.4/policies-pdk-prerequisites).

2.  Clone the
    [PDK Custom Policy GitHub Repository](https://github.com/mulesoft/pdk-custom-policy-examples)
    using the following command or your preferred GitHub interface:

    ```ssh
    git clone https://github.com/mulesoft/pdk-custom-policy-examples.git
    ```

3.  Navigate to the newly cloned directory, then copy and paste the directory of your desired policy
    into a new location.

4.  In the `cargo.toml` file of the copied policy example, replace the `group-id` with your group
    ID, for example:

    ```toml
    group_id = "<your-group-id>"
    ```

5.  Run the `make setup` command:

    ```ssh
    make setup
    ```

6.  Navigate to the `README.md` file in the example policy to read more about the policy and how to
    test it.

## See Also

- [Implementing Your Custom Policy Features in Rust](https://docs.mulesoft.com/pdk/1.4/policies-pdk-configure-features)
