from How does one change a username via the API? - #2 by blake :
Try this endpoint instead:
curl -i -sS -X PUT "http://127.0.0.1:3000/u/blake/preferences/username.json" \ -H "Content-Type: multipart/form-data;" \ -F "api_key=a66d01fbe98cc51b2747d8bfe99f81d7adca18317fbf3c43aa20f340d8e25bfe" \ -F "api_username=system" \ -F "new_username=blake2"
And it will output:
{"id":1,"username":"blake2"}