Hello @n0ah
Correct, both calls replace the full list. There is no endpoint that adds or removes a single member.
PUT /api/v1/groups/:groupId/members replaces all members of that group.
PUT /api/v1/users/:userId/groups replaces that user's memberships in local groups.
Memberships in external LDAP groups are left alone.
So it is read, modify, write.
I would use the per-user endpoint, since it only changes that one user.
With /groups/:groupId/members, two clients adding different users to the same group at the same time can overwrite each other.
USER_ID=uid-xxx
GROUP_ID=gid-yyy
CURRENT=$(curl -s -H "Authorization: Bearer $TOKEN" "https://my.example.com/api/v1/users/$USER_ID" | yq -p json -o json -I0 '.groupIds')
curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
"https://my.example.com/api/v1/users/$USER_ID/groups" \
-d "{\"groupIds\": $(echo "$CURRENT" | yq -p json -o json -I0 ". + [\"$GROUP_ID\"] | unique")}"