---
schema_version: "1"
id: 6f403861462c476eca7148461ec1b7cf2445b47da5a5c1265590293c5108da11
title: Accessing Policy Metadata
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/pdk/1.3/policies-pdk-configure-features-metadata.md
canonical_url: https://docs.mulesoft.com/pdk/1.3/policies-pdk-configure-features-metadata
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 1ebf922667fc517c79931c414c31f70f31774d57cd0737b53ae1ca40a1949a25
description: MuleSoft Documentation Site
release: "1.3"
latest: false
---
---
product: Omni Gateway Policy Development Kit (PDK)
version: 1.3
---

# Accessing Policy Metadata

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

PDK exposes a `Metadata` injectable that provides metadata about the policy, the Flex instance, the
API instance, and the Anypoint Organization. The `Metadata` struct is as follows:

```Rust
pub struct Metadata {
    pub flex_metadata: FlexMetadata,
    pub policy_metadata: PolicyMetadata,
    pub api_metadata: ApiMetadata,
    pub platform_metadata: PlatformMetadata,
}
```

The `Metadata` struct references the following structures:

- `FlexMetadata`:

  ```Rust
  pub struct FlexMetadata {
      pub flex_name: String,
      pub flex_version: String,
  }
  ```

- `PolicyMetadata`:

  ```Rust
  pub struct PolicyMetadata {
      pub policy_name: String,
      pub policy_namespace: String,
  }
  ```

- `ApiMetadata`:

  ```Rust
  pub struct ApiMetadata {
      pub id: Option<String>,
      pub name: Option<String>,
      pub version: Option<String>,
      pub slas: Option<Vec<ApiSla>>, // API SLA tiers in the platform
  }

  // Each ApiSla contains the limits for each SLA.
  pub struct ApiSla {
      pub id: String,
      pub tiers: Vec<Tier>, // Limits within an API SLA tier in the platform
  }
  ```

- `PlatformMetadata`:

  ```Rust
  pub struct PlatformMetadata {
      pub organization_id: String,
      pub environment_id: String,
      pub root_organization_id: String,
  }
  ```

## Inject Metadata into the #\[entrypoint\]

To inject metadata into the `#[entrypoint]` configuration function, see the following code snippet:

```Rust
#[entrypoint]
async fn configure(launcher: Launcher, metadata: Metadata) -> Result<()> {
    logger::info!("Flex instance name is: {}", metadata.flex_metadata.flex_name.to_string());

    launcher
        .launch(on_request(filter))
        .await?;
    Ok(())
}
```

## Inject Metadata into the Wrapped Functions

You cannot directly inject metadata into the wrapped functions. To use metadata in the wrapped
functions, first inject the data into the `#[entrypoint]` function and then the wrapped function:

```Rust
#[entrypoint]
async fn configure(launcher: Launcher, metadata: Metadata) -> Result<()> {
    launcher
        .launch(on_request(|r| request_filter(r, &metadata)))
        .await?;
    Ok(())
}

async fn request_filter(_: RequestState, metadata: &Metadata) -> Flow<()> {
    let mut vec = Vec::new();
    let headers = &mut vec;
    headers.push((
        "flex_name".to_string(),
        metadata.flex_metadata.flex_name.to_string(),
    ));
    headers.push((
        "policy_name".to_string(),
        metadata.policy_metadata.policy_name.to_string(),
    ));

    Flow::Break(Response::new(201).with_headers(vec))
}
```

## See Also

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