# Can we create roles and users using JAVA api

**URL:** <https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172>\
**Category:** Kibana\
**Created:** [August 20, 2018, 1:12pm UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172 "2018-08-20T13:12:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahendra\_Shinde](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Mahendra\_Shinde](https://discuss.elastic.co/u/Mahendra_Shinde)\
**Post date:** [August 20, 2018, 1:12pm UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172/1 "2018-08-20T13:12:29Z")

</div>

Can we create roles and users for kibana using Java API ?

Is there any link for documentation of such api?

I have X-pack enabled.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [August 20, 2018, 4:33pm UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172/2 "2018-08-20T16:33:27Z")

</div>

Hello ,  
oh I assume you are referring creating roles and users via [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html) ?

unfortunately, i haven't done so using that client to know if it's possible or not. Usually, those language clients end up calling the actual APIs. Just out of curiosity are you using Java API client ?

Another easier way would be to use Security APIs to create users and roles:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api.html)

Thanks  
Rashmi

---

<div class="post-metadata">

**Author:** ![Mahendra\_Shinde](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Mahendra\_Shinde](https://discuss.elastic.co/u/Mahendra_Shinde)\
**Post date:** [August 22, 2018, 5:04am UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172/3 "2018-08-22T05:04:03Z")

</div>

Hi Rashmi,

I am looking for security operation or user/roles management using java api.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [August 22, 2018, 4:18pm UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172/4 "2018-08-22T16:18:02Z")

</div>

So, you can get a handle to the java api client via [https://www.elastic.co/guide/en/x-pack/current/java-clients.html#security-client](https://www.elastic.co/guide/en/x-pack/current/java-clients.html#security-client)

beyond that, you will have to read the source here: [https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java#L235](https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java#L235)

Cheers  
Rashmi

---

<div class="post-metadata">

**Author:** ![Mahendra\_Shinde](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Mahendra\_Shinde](https://discuss.elastic.co/u/Mahendra_Shinde)\
**Post date:** [August 23, 2018, 1:21pm UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172/5 "2018-08-23T13:21:30Z")

</div>

Hi Rashmi,  
Thank you. I was looking for [SecurityClient.java](https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java#L235) only.

---

<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:** [September 20, 2018, 1:21pm UTC](https://discuss.elastic.co/t/can-we-create-roles-and-users-using-java-api/145172/6 "2018-09-20T13:21:35Z")

</div>

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