# Network-Key Replacement

{% hint style="info" %}
This feature is designed for very specific use cases only. Please consult your Account Manager before using it.
{% endhint %}

* This feature enables you to replace the Infeed-Banner placement and Banner Cache network keys with custom values you provide.
* It substitutes placeholders enclosed in curly brackets (`{}`) within the ad network key or `extraInfo` with corresponding values from your map. For example:
  * ```kotlin
    request.networkKeyReplacements = mapOf(
                "key1" to "value1",
                "key2" to "value2",
                "anotherKey" to "anotherValue"
            )
    ```
  * A network key like `1234:{key1}-{anotherKey}` will be transformed into `1234:value1-anotherValue`.

**Infeed Banner Example**

```kotlin
val configuration = BannerConfiguration()
placement = AATKit.createInfeedBannerPlacement("<PLACEMENT_NAME>", configuration)

// Create the banner request instance
val request = BannerRequest(null)
// Set network-key replacement
request.networkKeyReplacements = mapOf(
    "key1" to "value1",
    "key2" to "value2",
    "anotherKey" to "anotherValue"
)

// Perform the request
placement?.requestAd(request, object : BannerRequestCompletionListener {
    override fun onRequestCompleted(layout: BannerPlacementLayout?, error: BannerRequestError?) {
        // handle error or display the ad
    }
})
```

**Banner Cache Example**

```kotlin
val configuration = BannerCacheConfiguration("<PLACEMENT_NAME>", 1)

// Create the banner request instance
val request = BannerRequest(null)
// Set network-key replacement
request.networkKeyReplacements = mapOf(
    "key1" to "value1",
    "key2" to "value2",
    "anotherKey" to "anotherValue"
)

// Set configuration banner request
configuration.requestConfiguration = request

// Create the banner cache (once it has been created, it would start loading automatically)
bannerCache = AATKit.createBannerCache(configuration)
```

\
