---
schema_version: "1"
id: 60a5b44382b44c32849117f1bf881a30e69316904efed9b4b8232447fe2b35eb
title: Using Third-Party Libraries
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/pdk/1.2/policies-pdk-configure-features-libraries.md
canonical_url: https://docs.mulesoft.com/pdk/1.2/policies-pdk-configure-features-libraries
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 965413c38b4c344667c30a7a8ced35bf4e39ccf8df2e4e72cbee216344d3602f
description: MuleSoft Documentation Site
release: "1.2"
latest: false
---
---
product: Omni Gateway Policy Development Kit (PDK)
version: 1.2
---

# Using Third-Party Libraries

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

> [!NOTE] To view an example policy project that uses third-party libraries, see
> [Crypto Policy Example](https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.2.0/crypto/README.md).

Proxy Wasm defines a low level binary application interface (abi), that limits the system calls a
library can make. All third-party libraries included in your policy must be compatible with the
`wasm32-wasi` Rust compilation target.

To define a library such as `serde_urlencoded`, add it to the dependency list in `cargo.toml`:

```toml
[dependencies]
...
serde_urlencoded = "0.7.0"
```

Defining libraries enables you to use functions in `lib.rs` such as:

```Rust
serde_urlencoded::to_string([("token", "myToken")])
```

Libraries that interact with an external service like a database, or perform a system call like
reading a file, are usually not compatible with the `wasm32-wasi` target.

If your policy interacts with external services, use the Flex Gateway exposed `HttpClient`. For more
information about performing an HTTP call, see
[Performing an HTTP Call](https://docs.mulesoft.com/pdk/1.2/policies-pdk-configure-features-http-request).

It is possible that some libraries compile properly to the `wasm32-wasi` target but don’t work
properly when deployed to Flex Gateway. Example errors include:

- `Failed to load Wasm module due to a missing import: …​`

- `Wasm VM failed to initialize Wasm code`

- `Plugin configured to fail closed failed to load`

In these cases, contact the owners of the third-party library, or use a different library.

## See Also

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