# How to create readonly public API Key?

**URL:** https://discuss.elastic.co/t/how-to-create-readonly-public-api-key/326270
**Category:** Kibana
**Tags:** elastic-stack-security
**Created:** [February 23, 2023, 7:08am UTC](https://discuss.elastic.co/t/how-to-create-readonly-public-api-key/326270 "2023-02-23T07:08:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![indicozy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/indicozy/32/117448_2.png) [@indicozy](https://discuss.elastic.co/u/indicozy)
#### Post date: [February 23, 2023, 7:08am UTC](https://discuss.elastic.co/t/how-to-create-readonly-public-api-key/326270/1 "2023-02-23T07:08:45Z")

</div>

I'm trying to create an API Key for users to search on my frontend, however, I cannot find configuration example for readonly users to specific indices. Could you please share your config for this setting?

![image](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bdc82a16a901c3f8e1515dbce8c70384005be588.png)

---

<div class="post-metadata">

### Author: ![Yang\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yang_wang/32/48857_2.png) [@Yang\_Wang](https://discuss.elastic.co/u/Yang_Wang)
#### Post date: [February 24, 2023, 2:15am UTC](https://discuss.elastic.co/t/how-to-create-readonly-public-api-key/326270/2 "2023-02-24T02:15:20Z")

</div>

The [CreateApiKey API doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html) page gives an [example](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html#security-api-create-api-key-example) on how read only access can be granted over an index pattern of `index-a*`. It also links to the [CreateRole API doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) page for details since they share the same role descriptor syntax. Please let me know if they are helpful.

---

<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: [March 24, 2023, 2:16am UTC](https://discuss.elastic.co/t/how-to-create-readonly-public-api-key/326270/3 "2023-03-24T02:16:09Z")

</div>

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