How to update a username in Mattermost

I just had a question from one of our customers this week, asking how to update a username as an administrator. Since this is only possible for the user and not the admin right now I was thinking of the platform command (which will be renamed to mattermost in the future!) but right now there`s no attribute change implemented.

Since every call goes thru the API I checked out API documentation: https://api.mattermost.com

With this we can patch and update users easily using cUrl and here is how it’s done.

1. Get the User ID from the user you want to change (Mattermost Server console):

cd /opt/mattermost
sudo ./bin/platform user search USERNAME

2. Copy the User ID of the user you want to change.

3. Authorize your requests against the Mattermost Server:

curl -i -d '{"login_id":"ADMINUSER","password":"ADMINPASSWORD"}' http://YOURMMSERVER:8065/api/v4/users/login

4. Use the Autorization-Token and the User ID to upadte the user:

curl -X PUT -H 'Authorization: Bearer YOURAUTHTOKEN' -d '{"username":"NEWUSERNAME"}' http://YOURMMSERVER:8065/api/v4/users/USERID/patch

After the successful run you can validate the result in the console and System Console.

and System Console.

 

 

 

Leave a Reply