# POST method to create role and grant privilege in spaces

**URL:** <https://discuss.elastic.co/t/post-method-to-create-role-and-grant-privilege-in-spaces/237995>\
**Category:** Kibana\
**Created:** [June 22, 2020, 4:34am UTC](https://discuss.elastic.co/t/post-method-to-create-role-and-grant-privilege-in-spaces/237995 "2020-06-22T04:34:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nameisnotimportant](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@nameisnotimportant](https://discuss.elastic.co/u/nameisnotimportant)\
**Post date:** [June 22, 2020, 4:34am UTC](https://discuss.elastic.co/t/post-method-to-create-role-and-grant-privilege-in-spaces/237995/1 "2020-06-22T04:34:36Z")

</div>

Hi,  
I am trying to figure out how to user DevTools to create role and grant privilege to spaces. I tried with below codes but it says failed to parse role [QA]. unexpected field [spaces]. May i know where can i find the document to create role and grant spaces privileges using POST ?

POST \_security/role/QA  
{  
"indices": [  
{  
"names": ["moha","amlorders"],  
"privileges": ["all"]  
}  
],  
"spaces": [{  
"Risk Profiling Space (RPS)" : ["all"]  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![nameisnotimportant](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@nameisnotimportant](https://discuss.elastic.co/u/nameisnotimportant)\
**Post date:** [June 26, 2020, 6:43am UTC](https://discuss.elastic.co/t/post-method-to-create-role-and-grant-privilege-in-spaces/237995/2 "2020-06-26T06:43:46Z")

</div>

In case someone needed, the following is the answer:

POST \_security/role/QA  
{  
"indices": [  
{  
"names": ["moha","amlorders"],  
"privileges": ["all"]  
}  
],  
"applications": [  
{  
"application": "kibana-.kibana",  
"privileges" : [  
"feature\_dashboard.all",  
"feature\_visualize.all",  
"feature\_discover.all"  
],  
"resources" : ["\*"]  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![azasypkin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/azasypkin/32/42216_2.png) [@azasypkin](https://discuss.elastic.co/u/azasypkin)\
**Post date:** [June 29, 2020, 11:05am UTC](https://discuss.elastic.co/t/post-method-to-create-role-and-grant-privilege-in-spaces/237995/3 "2020-06-29T11:05:13Z")

</div>

Hi @nameisnotimportant,

Glad you have found an answer, but be aware that DevTools work with Elasticsearch directly and Spaces is a Kibana-only concept, so the request you have may not work as you expect in the future versions or even in this version. That's why you should use [Kibana APIs](https://www.elastic.co/guide/en/kibana/current/role-management-api.html) to create Spaces-aware roles instead (e.g. with `cURL`, since DevTools cannot work with Kibana API endpoints).

Best,  
Oleg

---

<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:** [July 27, 2020, 11:05am UTC](https://discuss.elastic.co/t/post-method-to-create-role-and-grant-privilege-in-spaces/237995/4 "2020-07-27T11:05:16Z")

</div>

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