# Groups API - manually syncing group membership?

**URL:** <https://meta.discourse.org/t/groups-api-manually-syncing-group-membership/154521>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [June 11, 2020, 1:15pm UTC](https://meta.discourse.org/t/groups-api-manually-syncing-group-membership/154521 "2020-06-11T13:15:24Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Judith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/judith/32/289903_2.png) [@Judith](https://meta.discourse.org/u/Judith)\
**Post date:** [June 11, 2020, 1:15pm UTC](https://meta.discourse.org/t/groups-api-manually-syncing-group-membership/154521/1 "2020-06-11T13:15:25Z")

</div>

I seem to have boxed myself into a corner here..

I have a membership site (also in Rails) and I’m using the Discourse API in order to automatically create and populate restricted forum groups for all of my user groups. This works great; I’m even giving each group a wiki post to start with. (I’ve [posted my code](https://meta.discourse.org/t/providing-restricted-subforums-for-external-groups/139107).)

Now I’ve come across the issue that sometimes I need to manually sync up the group membership, for example when merging groups on my site or when the coordinator accidentally deleted/added people via the forum. For this purpose, I want to delete ALL Discourse group members and then re-add the ones that should be in it.

First problem: the Discourse API doesn’t seem to come with a DELETE ALL for group members, so I have to specify the names of everyone that should be deleted.

Second problem: I cannot actually retrieve the Discourse group’s current membership, because for whatever reason it’s asking me for the group NAME rather than ID. I’ve only stored the group ID on my site, because that’s what Discourse uses for the related PUT/POST/DELETE requests.

Third problem: It should be obvious, but I don’t see a way to retrieve the group’s name by supplying its ID, unless I want to retrieve all 200+ groups and iterate through them until I find one whose ID matches. This seems a ridiculous amount of trouble and also contravenes Rails conventions.

What am I missing?

EDIT: @codinghorror was really helpful last time - any ideas now?

---

_[View the full topic](https://meta.discourse.org/t/groups-api-manually-syncing-group-membership/154521)._
