# Cannot update group owners via Ruby or REST API

**URL:** https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253
**Category:** Development
**Tags:** rest-api
**Created:** [September 28, 2018, 6:17am UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253 "2018-09-28T06:17:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [September 28, 2018, 6:17am UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/1 "2018-09-28T06:17:30Z")

</div>

The ruby API [shows an option to assign `owner_usernames`](https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/groups.rb#L54) on `create_group` and `update_group`. The `create_group` seems to work (and the owner is there after the group is created) but it appears that `owner_usernames` are only assignable on `create` [on the REST side of things](https://github.com/discourse/discourse/blob/master/app/controllers/admin/groups_controller.rb#L45). So we can’t promote a user to an existing group owner without the UI (at least with the Ruby API).

Is this by design or is this worth a PR? Am I correct in assuming the Ruby side of things would need matching methods for `groups#add_owners` and `groups#remove_owner`?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [September 28, 2018, 6:23am UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/2 "2018-09-28T06:23:19Z")

</div>

The UI is using the API. Have you tried this?

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [September 28, 2018, 6:25am UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/3 "2018-09-28T06:25:30Z")

</div>

Thanks, Régis. I’m not seeing anything for ownership in [discourse\_api/lib/discourse\_api/api/groups.rb at main · discourse/discourse\_api · GitHub](https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/groups.rb). I was just checking to make sure I wasn’t missing something. I can certainly just do a put request to the `/admin/groups/:group_name/owners` API endpoint directly without a method in the Ruby API.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 2, 2018, 5:56am UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/4 "2018-11-02T05:56:14Z")

</div>

The API gem may have some gaps, if you find any feel free to plug them in with PRs.

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/2/520d04eb0b8374bb4b58b8ef99074f406106fa85.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/6/56249468444455bb1629941bf25b251c0c07da21.png)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 8, 2021, 7:20pm UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/5 "2021-08-08T19:20:58Z")

</div>



---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 10, 2021, 2:10pm UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/6 "2021-08-10T14:10:19Z")

</div>

Methods for adding and removing group owners now exist in the discourse\_api gem.

[https://github.com/discourse/discourse\_api/pull/239](https://github.com/discourse/discourse_api/pull/239)

```ruby
@client.group_add_owners(41, { usernames: "48ce9df193c627574202" } )
@client.group_remove_owners(41, { usernames: "48ce9df193c627574202" } )

```

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 10, 2021, 2:10pm UTC](https://meta.discourse.org/t/cannot-update-group-owners-via-ruby-or-rest-api/98253/7 "2021-08-10T14:10:26Z")

</div>


