# Remove groups from User via REST API

**URL:** <https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311>\
**Category:** Sonatype Nexus Repository\
**Created:** [March 1, 2022, 2:48pm UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311 "2022-03-01T14:48:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tibor.dudas](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@tibor.dudas](https://community.sonatype.com/u/tibor.dudas)\
**Post date:** [March 1, 2022, 2:48pm UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/1 "2022-03-01T14:48:08Z")

</div>

I had a look at the REST API of NEXUS, but did not find how to remove groups from users. We would like to automize this task.  
Is it possible to do so via REST API at all?  
Thanks for an answer…

---

<div class="post-metadata">

**Author:** ![mmartz](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mmartz](https://community.sonatype.com/u/mmartz)\
**Post date:** [March 1, 2022, 4:39pm UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/2 "2022-03-01T16:39:30Z")

</div>

Does the `PUT /v1/rest/security/users/{userId}` API not do exactly that? Just change the list of roles on the user to remove a role from them.

---

<div class="post-metadata">

**Author:** ![tibor.dudas](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@tibor.dudas](https://community.sonatype.com/u/tibor.dudas)\
**Post date:** [March 4, 2022, 9:51am UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/3 "2022-03-04T09:51:59Z")

</div>

Is there any documentation about it?

I understand your point, but could you be more precise or give an example, please?

---

<div class="post-metadata">

**Author:** ![mmartz](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mmartz](https://community.sonatype.com/u/mmartz)\
**Post date:** [March 4, 2022, 2:23pm UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/4 "2022-03-04T14:23:05Z")

</div>

All the rest APIs are documented in product under Admin \> System \> API. You’d probably want to `GET /v1/rest/security/users/{userId}`, parse the resulting json and remove the role from the list of roles, then `PUT /v1/rest/security/users/{userId}` with the modified json to remove a role from a user.

---

<div class="post-metadata">

**Author:** ![tibor.dudas](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@tibor.dudas](https://community.sonatype.com/u/tibor.dudas)\
**Post date:** [March 10, 2022, 1:46pm UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/5 "2022-03-10T13:46:37Z")

</div>

Thanks.  
I managed to communicate with the rest api through the nexus-gui under api, but not from the command line of the linux server hosting nexus:  
curl -v -su ‘USER’ --noproxy ‘\*’ -X GET ‘[https://127.0.0.1/service/rest/v1/status](https://127.0.0.1/service/rest/v1/status)’ -H “Content-Type: application/json”  
Enter host password for user USER:

- About to connect() to 127.0.0.1 port 443 (#0)
- Trying 127.0.0.1…
- Connection refused
- Failed connect to 127.0.0.1:443; Connection refused
- Closing connection 0

Is some configuration missing to allow using the rest api via command line?  
The USER has all rights granted.

---

<div class="post-metadata">

**Author:** ![tibor.dudas](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@tibor.dudas](https://community.sonatype.com/u/tibor.dudas)\
**Post date:** [March 25, 2022, 10:41am UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/6 "2022-03-25T10:41:21Z")

</div>

It is http on localhost.

---

<div class="post-metadata">

**Author:** ![alizade.fateme78](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/alizade.fateme78/32/2521_2.png) [@alizade.fateme78](https://community.sonatype.com/u/alizade.fateme78)\
**Post date:** [January 4, 2023, 8:59am UTC](https://community.sonatype.com/t/remove-groups-from-user-via-rest-api/8311/7 "2023-01-04T08:59:23Z")

</div>

Hello,  
I’ve searched a lot about nexus REST API documentation and here is what I’ve found:  
`<nexus URL>/service/rest/swagger.json`  
You can see lots of endpoints here but for example, for retrieving users you can use this API :  
`<nexus url>/service/rest/beta/security/users`  
in case you had any questions about other APIs, just let me know. Maybe I could help 🙂
