# Create new or obtain default private-api-key

**URL:** <https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [December 6, 2020, 11:43pm UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789 "2020-12-06T23:43:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ismarslomic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ismarslomic/32/63870_2.png) [@ismarslomic](https://discuss.elastic.co/u/ismarslomic)\
**Post date:** [December 6, 2020, 11:43pm UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789/1 "2020-12-06T23:43:26Z")

</div>

Is it possible to automate creation of API Keys (private and search) without needing to do manually steps in Enterprise Search / App Search UI first?

We have 4 environments and treats infrastructure and platforms-as-a-code. Currently it seems like it is not possible to define the **key** of default created private-api-key, nor create new ones by configuration of Enterprise Search. Wich makes us need to manually go into Apps Search UI, and create new keys.

Any idea how we can automate configuration of API Keys, so we can avoid manual use of App Search UO

Im deploying ECK 1.3 and Elastic Stack v7.10.0 on Kubernetes

---

<div class="post-metadata">

**Author:** ![MadsOhm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/madsohm/32/69154_2.png) [@MadsOhm](https://discuss.elastic.co/u/MadsOhm)\
**Post date:** [December 7, 2020, 7:17am UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789/2 "2020-12-07T07:17:44Z")

</div>

Hi ismarslomic 👋

This documentation page shows how to create new API keys [https://www.elastic.co/guide/en/app-search/7.9/credentials.html#credentials-create](https://www.elastic.co/guide/en/app-search/7.9/credentials.html#credentials-create), but I feel that's not what you're asking?

You want to be able to define an API key that Enterprise Search is "born" with out of your Kubernetes code?

---

<div class="post-metadata">

**Author:** ![ismarslomic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ismarslomic/32/63870_2.png) [@ismarslomic](https://discuss.elastic.co/u/ismarslomic)\
**Post date:** [December 7, 2020, 9:01am UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789/3 "2020-12-07T09:01:30Z")

</div>

> [@MadsOhm](#):
>
> You want to be able to define an API key that Enterprise Search is "born" with out of your Kubernetes code?

You are correct! I have described what I really want in an duplicate post (sorry for that) here: [Create custom API Key for Enterprise Search/App Search in ECK through Kubernetes resource](https://discuss.elastic.co/t/create-custom-api-key-for-enterprise-search-app-search-in-eck-through-kubernetes-resource/257771). I would like to configure my API Keys as part of the Kubernetes resource spec, similar to configuring Elasticsearch Users by using [Elasticsearch File Realm](https://www.elastic.co/guide/en/cloud-on-k8s/1.3/k8s-users-and-roles.html#k8s_creating_custom_users).

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [December 7, 2020, 2:48pm UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789/4 "2020-12-07T14:48:43Z")

</div>

@ismarslomic There's no way to define API Keys in advance, they _must_ be generated with the API.

This is a little tricky to script currently, as the credentials API requires an admin key, which can only currently be created via the UI. However, starting in 7.11 we will support Basic Auth in our APIs which will makes this possible.

---

<div class="post-metadata">

**Author:** ![ismarslomic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ismarslomic/32/63870_2.png) [@ismarslomic](https://discuss.elastic.co/u/ismarslomic)\
**Post date:** [December 7, 2020, 6:09pm UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789/5 "2020-12-07T18:09:04Z")

</div>

Thanks @JasonStoltz! It would be even better if you could add support for managing API Keys with use of Kubernetes secrets, such as you already do for elasticsearch users. We strive to follow the [GitOps principles](https://www.gitops.tech/) for our infrastructure, platform, external tools and internal applications. And currently we have to do manual steps specifically for our elastic stack, which is kind of sad. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 4, 2021, 6:09pm UTC](https://discuss.elastic.co/t/create-new-or-obtain-default-private-api-key/257789/6 "2021-01-04T18:09:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
