# API. How can I add indexes to a role?

**URL:** <https://discuss.elastic.co/t/api-how-can-i-add-indexes-to-a-role/100748>\
**Category:** Elasticsearch\
**Created:** [September 16, 2017, 5:47am UTC](https://discuss.elastic.co/t/api-how-can-i-add-indexes-to-a-role/100748 "2017-09-16T05:47:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebirther](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rebirther/32/19228_2.png) [@rebirther](https://discuss.elastic.co/u/rebirther)\
**Post date:** [September 16, 2017, 5:47am UTC](https://discuss.elastic.co/t/api-how-can-i-add-indexes-to-a-role/100748/1 "2017-09-16T05:47:26Z")

</div>

Hello guys

Suppose there is a role:

> **Summary**
>
> ```auto
> #GET /_xpack/security/role/role-name
> 
> {
> "role-name": {
> "cluster": [
> "monitor",
> "manage_index_templates"
> ],
> "indices": [
> {
> "names": [
> "index1-*",
> "index2-*",
> "index3-*"
> ],
> "privileges": [
> "read",
> "write",
> "create_index"
> ],
> "field_security": {
> "grant": [
> "*"
> ]
> }
> }
> ],
> "run_as": [],
> "metadata": {},
> "transient_metadata": {
> "enabled": true
> }
> }
> }
> ```

What kind of request should I send to get this?:

> **Summary**
>
> ```auto
> {
> "role-name": {
> "cluster": [
> "monitor",
> "manage_index_templates"
> ],
> "indices": [
> {
> "names": [
> "index1-*",
> "index2-*",
> "index3-*"
> ],
> "privileges": [
> "read",
> "write",
> "create_index"
> ],
> "field_security": {
> "grant": [
> "*"
> ]
> }
> },
> {
> "names": [
> "index-other1-*"
> ],
> "privileges": [
> "read",
> "write",
> "create_index"
> ],
> "field_security": {
> "grant": [
> "*"
> ]
> }
> }
> ],
> "run_as": [],
> "metadata": {},
> "transient_metadata": {
> "enabled": true
> }
> }
> }
> ```

That is, I want to add privileges to another index.  
**Is there a way of not requesting current role permissions, but adding new permissions?**

I tried this method, but it overwrites the data:

> **Summary**
>
> ```auto
> #PUT /_xpack/security/role/role-name
> 
> {
> "indices": [
> {
> "names": [
> "index-other1-*"
> ],
> "privileges": [
> "read",
> "write",
> "create_index"
> ],
> "field_security" : {
> "grant" : [ 
> "*"
> ]
> }
> }
> ]
> }
> ```

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [September 16, 2017, 10:31pm UTC](https://discuss.elastic.co/t/api-how-can-i-add-indexes-to-a-role/100748/2 "2017-09-16T22:31:30Z")

</div>

There are no partial update options in the security APIs.

If you want to update a role, then you need to use a `GET` request, then merge your changes into the JSON and send that as a `PUT`.

---

<div class="post-metadata">

**Author:** ![rebirther](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rebirther/32/19228_2.png) [@rebirther](https://discuss.elastic.co/u/rebirther)\
**Post date:** [September 17, 2017, 2:00pm UTC](https://discuss.elastic.co/t/api-how-can-i-add-indexes-to-a-role/100748/3 "2017-09-17T14:00:59Z")

</div>

Thank you, Tim

That's exactly what I did

Is it worth hoping that when this method/request is added?  
Or is it absent for security/architecture reasons?

---

<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:** [October 15, 2017, 2:01pm UTC](https://discuss.elastic.co/t/api-how-can-i-add-indexes-to-a-role/100748/4 "2017-10-15T14:01:01Z")

</div>

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