---
schema_version: "1"
id: bb7747fb8e2e09ab8bbd7f031f932a560fa326fa92661f2c922b41128bc6ff14
title: Reporting Policy Violations
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/pdk/1.8/policies-pdk-configure-features-violations.md
canonical_url: https://docs.mulesoft.com/pdk/1.8/policies-pdk-configure-features-violations
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 80a2cd594ba307408b240b0726fe348761f02241fd184a10315281f93179d6a0
description: MuleSoft Documentation Site
release: "1.8"
latest: false
---
---
product: Omni Gateway Policy Development Kit (PDK)
version: 1.8
---

# Reporting Policy Violations

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

> [!NOTE] For an example of reporting policy violations, see
> [Stream Payload Policy](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.8.0/stream-payload/README.md).

PDK provides functions to report a policy violation. Reported policy violations appear in Anypoint
Monitoring.

Only one policy violation can be active for a request at a time. When a new violation occurs, it
overides any existing violation. If multiple policies generate violations for a single request, only
one violation appears in Anypoint Monitoring.

Reporting a policy violation doesn’t reject the request. To reject requests, see
[Stopping Request and Response Execution](https://docs.mulesoft.com/pdk/1.8/policies-pdk-configure-features-stop).

To view the current policy violation or generate a new policy violation, use these PDK functions:

```Rust
/// Returns the existing policy violation of the current request. Returns None if no violation exists.
pub fn policy_violation(&self) -> Option<PolicyViolation>;

/// Generates a new policy violation for the current request. If a violation was previously generated, the previous violation is overridden.
pub fn generate_policy_violation(&self);

/// Generates a new policy violation with the client application details for the current request. This overwrites any previous policy violations.
pub fn generate_policy_violation_for_client_app<T: Into<String>, K: Into<String>>(
   &self,
   client_name: T,
   client_id: K,
);
```

To retrieve information about the current policy violation, use these PDK functions:

```Rust
    /// The name of the policy that generated the violation
   pub fn get_policy_name(&self) -> &str;

   /// Client name associated with the violation, only available if a previous policy reported the client ID
   pub fn get_client_name(&self) -> Option<&str>;

   /// Client ID associated with the violation, only available if a previous policy reported the client ID
   pub fn get_client_id(&self) -> Option<&str>;
```

## See Also

- [Injecting Parameters](https://docs.mulesoft.com/pdk/1.8/policies-pdk-configure-features-inject-parameters)
