API:User group membership

Token
A user rights token is required and can since MediaWiki 1.24 be obtained by action=query&meta=tokens&type=userrights.

For compatibility, the token used in the web UI is also accepted.

Previously, to change a user's group membership, the required token would depend on the name of the user whose rights were being changed. A user rights token could be obtained as follows:

Adding users to and removing them from groups
Users can be added to groups or removed from them with action=userrights.

Sample request
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=userrights requires POST requests; GET requests will cause an error.

NOTE: If you don't have permission to add/remove users to/from groups, you'll get a result with empty  and   tags rather than an error message, because all the groups you specified were silently ignored.

Possible errors
All errors are formatted as: