# More efficient way to add a user to the group

**URL:** <https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324>\
**Category:** Community Support\
**Created:** [February 14, 2022, 3:20pm UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324 "2022-02-14T15:20:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucasfe4nor](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lucasfe4nor](https://forums.rocket.chat/u/lucasfe4nor)\
**Post date:** [February 14, 2022, 3:20pm UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324/1 "2022-02-14T15:20:47Z")

</div>

### Description

Is there a more efficient way to add a user to the group? let’s say I have 20 admin users and I want to create one more, after that I must add this user to all common user groups (so every common user is in a group with all admins). today to do this i make about 2k requests to add this admin user to groups and i don’t think it’s the best solution. Is there any rocket.chat feature that makes this easier?

Ty.

### Server Setup Information

- Version of Rocket.Chat Server: 3.10.7

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [February 15, 2022, 8:11pm UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324/2 "2022-02-15T20:11:51Z")

</div>

Hi!

You can easily create a script that can do almost anything, from creating users, adding to channels, groups, teams, applying roles, configuring Rocket.Chat and what not using our Rest APIs.

My go to language is Python, so I would use this library (optional):

> **[GitHub - jadolg/rocketchat\_API: Python API wrapper for Rocket.Chat](https://github.com/jadolg/rocketchat_API/)**
>
> Python API wrapper for Rocket.Chat. Contribute to jadolg/rocketchat\_API development by creating an account on GitHub.

to consume those APIs and accomplish what you need:

> **[REST API](https://developer.rocket.chat/reference/api/rest-api)**

---

<div class="post-metadata">

**Author:** ![lucasfe4nor](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lucasfe4nor](https://forums.rocket.chat/u/lucasfe4nor)\
**Post date:** [February 15, 2022, 8:27pm UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324/3 "2022-02-15T20:27:15Z")

</div>

Hi. Isn’t there a more efficient way? If I have to add a user to 2000 groups, then do I have to make 2000 requests?

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [February 15, 2022, 8:58pm UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324/4 "2022-02-15T20:58:13Z")

</div>

Oh. Sorry!

I completely missed that your probably considered this approach and the 2k were literal 🤣

Looks like we can probably do something. I just discovered an undocumented feature.

This is the code for the API

> <https://github.com/RocketChat/Rocket.Chat/blob/7632f12cfcc7ed8ee8f843587fdff63b101cc765/app/api/server/v1/channels.js#L499>

that will eventually use this code here:

> <https://github.com/RocketChat/Rocket.Chat/blob/157b882d38b34b7b79dea527316554fe33f70891/app/api/server/helpers/getUserFromParams.js#L29>

Turns out the payload to that API could be something like

```auto
{ "roomId": "YcJbJEeRh3CmXrNav", "userIds": ["zyYbkJ4dy69et7uwC", "DHm5KWrYSZoQpRyyJ"] }

```

instead of

```auto
{ "roomId": "ByehQjC44FwMeiLbX", "userId": "nSYqWzZ4GsKTX4dyK" }

```

Let me know if this works, or what API are you using specifically.

Thanks!

---

<div class="post-metadata">

**Author:** ![lucasfe4nor](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lucasfe4nor](https://forums.rocket.chat/u/lucasfe4nor)\
**Post date:** [February 16, 2022, 12:48am UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324/5 "2022-02-16T00:48:34Z")

</div>

I need the opposite ☹ … an array of roomIds for a user.

I’m using REST API without a wrapper.  
Version of Rocket.Chat Server: 3.10.7

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [February 18, 2022, 1:04pm UTC](https://forums.rocket.chat/t/more-efficient-way-to-add-a-user-to-the-group/13324/7 "2022-02-18T13:04:55Z")

</div>

I figured that.

But that’s the place to change it. We can open a feature request for that, so we can discover if we have more users that would benefit from this feature.
