jvu if you inspect a network request while changing groups you'll see the format.
Basically you need to provide a data.relationships.groups
array in JSON:API syntax.
Flarum doesn't actually look at all the type
properties or even data.id
, it just reads the tag IDs I believe, so something like this should work (untested):
PATCH /api/users/<id>
{
"data": {
"relationships": {
"groups": [
{
"id": "2"
}
]
}
}
}
You need to repeat existing groups, otherwise they will be removed. You might need to GET /api/users/<id>
first to retrieve existing groups.
Using the Flarum extension API you could add a new endpoint that only adds/removed a specific group without a need to fetch and repeat existing groups.