# Is there anyway to add tenant by rest api?

**URL:** <https://forum.search-guard.com/t/is-there-anyway-to-add-tenant-by-rest-api/763>\
**Category:** Search Guard\
**Created:** [January 30, 2018, 8:58am UTC](https://forum.search-guard.com/t/is-there-anyway-to-add-tenant-by-rest-api/763 "2018-01-30T08:58:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johnson\_C](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@Johnson\_C](https://forum.search-guard.com/u/Johnson_C)\
**Post date:** [January 30, 2018, 8:58am UTC](https://forum.search-guard.com/t/is-there-anyway-to-add-tenant-by-rest-api/763/1 "2018-01-30T08:58:21Z")

</div>

I want to use search guard multi-tenancy, i can add tenant by modify sg\_config.xml.  
Is there anyway I can add tenant and assign tenant by rest api?

---

<div class="post-metadata">

**Author:** ![jkressin](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/jkressin/32/9_2.png) [@jkressin](https://forum.search-guard.com/u/jkressin)\
**Post date:** [January 30, 2018, 1:04pm UTC](https://forum.search-guard.com/t/is-there-anyway-to-add-tenant-by-rest-api/763/2 "2018-01-30T13:04:19Z")

</div>

It’s possible with the roles endpoint, but indeed this part is missing in the documentation. Thanks for letting us know, we will add it accordingly.

You can add the tenants to a role like that:

{

“cluster” : [“”, “”, …],

“indices” : {

“” : {

“” : [“\<index/type permission\>”, “\<index/type permission\>”, …],

“_dls_”: “”

“_fls_”: [“field”, “field”]

},

“” : {

“” : [“\<index/type permission\>”, “\<index/type permission\>”, …],

}  
“tenants”: {  
 : \<RW | RO\>,  
 : \<RW | RO\>,  
…  
}

}

}

``

.

> **···**
>
> On Tuesday, January 30, 2018 at 9:58:21 AM UTC+1, Johnson C wrote:
> 
> > I want to use search guard multi-tenancy, i can add tenant by modify sg\_config.xml.  
> > Is there anyway I can add tenant and assign tenant by rest api?
