# Creating an APIkey when declaratively creating a KongCredential

**URL:** <https://discuss.konghq.com/t/creating-an-apikey-when-declaratively-creating-a-kongcredential/4163>\
**Category:** General\
**Created:** [August 5, 2019, 7:27pm UTC](https://discuss.konghq.com/t/creating-an-apikey-when-declaratively-creating-a-kongcredential/4163 "2019-08-05T19:27:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Bosterito95](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Bosterito95](https://discuss.konghq.com/u/Bosterito95)\
**Post date:** [August 5, 2019, 9:02pm UTC](https://discuss.konghq.com/t/creating-an-apikey-when-declaratively-creating-a-kongcredential/4163/3 "2019-08-05T21:02:42Z")

</div>

@hbagdi thanks for the quick response. Yup - is there a way to make this a secret/ hashed? It seems like a security risk to be able to just create keys when something like this is doable:

> [@Scoping of KongCredentials](https://discuss.konghq.com/t/scoping-of-kongcredentials/3160/2):
>
> Hello @jmtoball, Thank you for the detailed explanation. Is this expected? Is this a bug? Is there a better way to do this, apart from creating a namespace per endpoint? This is not a bug but an expected behavior. The Ingress Controller doesn’t enforce any k8s namespace level scopes in Kong. Any consumer with valid credential will be authenticated by Kong, no matter which namespace it belongs to. There are a couple of ways to solve this problem: Run an Ingress Controller in each namesp…

---

_[View the full topic](https://discuss.konghq.com/t/creating-an-apikey-when-declaratively-creating-a-kongcredential/4163)._
