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

# Custom Policy Examples

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

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

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

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

- [Data Storage Stats Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.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.9/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.9.0/dataweave/README.md):
  Use the DataWeave Policy as an example of how to handle
  [custom DataWeave expressions](https://docs.mulesoft.com/pdk/1.9/policies-pdk-configure-features-dataweave) in your custom policy.

- [IP Filter Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.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.9/policies-pdk-configure-features-ip-filter).

- [JSON Validation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.0/json-validation/README.md):
  Use the JSON Validation Policy as an example of how to enforce JSON payload limits with the
  [JSON Validator library](https://docs.mulesoft.com/pdk/1.9/policies-pdk-configure-features-json-validator).

- [JWT Generation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.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.9/policies-pdk-configure-features-jwt#create-jwt-token).

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

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

- [OAuth 2.0 Token Introspection Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.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.9/policies-pdk-configure-features-token-introspection) in your custom policy.

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

- [Spike Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.0/spike/README.md):
  Use the Spike Policy as an example of how to implement spike arrest with the
  [Spike Control library](https://docs.mulesoft.com/pdk/1.9/policies-pdk-configure-features-spike-control) and periodic ticking with
  [Timer functions](https://docs.mulesoft.com/pdk/1.9/policies-pdk-configure-features-timer).

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

- [TLS Calls Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.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 Omni Gateway.

- [WebSocket Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.0/websocket/README.md):
  Use the WebSocket Policy as an example of how to
  [support WebSocket APIs](https://docs.mulesoft.com/pdk/1.9/policies-pdk-configure-features-websocket) and process bidirectional
  frames in your custom policy.

- [XML Validation Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.9.0/xml-validation/README.md):
  Use the XML Validation Policy as an example of how to enforce XML payload limits with the
  [XML Validator library](https://docs.mulesoft.com/pdk/1.9/policies-pdk-configure-features-xml-validator).

## A2A and MCP Server Policy Examples

PDK includes the following A2A and MCP example policies:

- [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.

- [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.

## 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.9/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.9/policies-pdk-configure-features)
