Read API value from gradle.properties via Kotlin DSL

I am saving my apiKey on my gradle.properties in my manifest I need to pass a value for the meta-data which is the apiKey and i am trying to use value = ${myApiKey}" how do I access the gradle.properties in the build.gradle.kts and use my {myApiKey} in my manifest. This is similar to what I want to achieve but I am wondering where do I put

 buildConfigField("String", "API_KEY", getApiKey())

considering I have different build variants.