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

# 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.6.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.7/policies-pdk-configure-features-timer) and
  [HTTP calls](https://docs.mulesoft.com/pdk/1.7/policies-pdk-configure-features-http-request).

- [Certification Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.6.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.7/policies-pdk-configure-features-cors) in your custom policy.

- [Crypto Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.0/crypto/README.md):
  Use the Crypto Policy as an example of how to use
  [third-party libraries](https://docs.mulesoft.com/pdk/1.7/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.6.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.7/policies-pdk-configure-features-caching) in your custom policy.

- [Data Storage Stats Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.0/data-storage-stats/README.md):
  Use the Data Storage Stats Policy as an example of how to implement
  [data storage](https://docs.mulesoft.com/pdk/1.7/policies-pdk-configure-features-data-storage) with both local (in-memory) and
  shared (Redis) data storage.

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

- [JWT Validation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.7/policies-pdk-configure-features-jwt) in your custom policy.

- [JWT Generation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.0/jwt-generation/README.md):
  Use the JWT Generation Policy as an example of how to generate JWT tokens using the
  [JWT generation function](https://docs.mulesoft.com/pdk/1.7/policies-pdk-configure-features-jwt#create-jwt-token).

- [OAuth 2.0 Token Introspection Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.0/oauth-2-token-introspection/README.md):
  Use the OAuth 2.0 Token Introspection Policy as an example of how to use
  [Token Introspection](https://docs.mulesoft.com/pdk/1.7/policies-pdk-configure-features-token-introspection) in your custom policy.

- [Metrics Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.7/policies-pdk-configure-features-timer) and
  [HTTP calls](https://docs.mulesoft.com/pdk/1.7/policies-pdk-configure-features-http-request).

- [IP Filter Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.0/ip-filter/README.md):
  Use the IP Filter Policy as an example of how to extract client IPs from request headers and
  implement IP-based access control using PDK’s
  [IP Filter feature](https://docs.mulesoft.com/pdk/1.7/policies-pdk-configure-features-ip-filter).

- [Query Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.6.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.7/policies-pdk-configure-features-http-request) in your custom policy.

- [Spike Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.7/policies-pdk-configure-features-timer).

- [Stream Payload Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.7/policies-pdk-configure-features-headers#streaming-bodies).

- [TLS Calls Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.6.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.7/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.7/policies-pdk-configure-features)
