# 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:** 4

<div class="post-metadata">

**Author:** ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)\
**Post date:** [June 15, 2020, 2:08pm UTC](https://meta.discourse.org/t/groups-api-manually-syncing-group-membership/154521/4 "2020-06-15T14:08:31Z")

</div>

> [@Judith](#):
>
> 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.

You seem to be right on this – you cannot access group resources with the ID number, only the name.

> <https://github.com/discourse/discourse/blob/70e50a2255ebb30c78891a7f846e833ab85b0a8b/app/controllers/groups_controller.rb#L113>

The ID referenced here is not an ID, but the name, per

> <https://github.com/discourse/discourse/blob/70e50a2255ebb30c78891a7f846e833ab85b0a8b/app/controllers/groups_controller.rb#L569>

It probably makes sense to refactor the `/g/<group-name>` route to match how we now handle topics and categories. Something like `/g/<group-name>/<id>` or `/g/patrons/41` and allow `/g/41` to function the same way.

Until we fix that up, though, it seems the only way to accomplish what you’re looking for is:

1. Storing the group name alongside the id
2. Hitting `g/<group-name>/members.json` with a GET request to get the members
3. Loop through those to delete each so you can re-sync.

---

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