# How does one change a username via the API?

**URL:** https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118
**Category:** Support
**Created:** [August 31, 2018, 9:05pm UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118 "2018-08-31T21:05:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jezra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jezra/32/105986_2.png) [@jezra](https://meta.discourse.org/u/jezra)
#### Post date: [August 31, 2018, 9:05pm UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/1 "2018-08-31T21:05:51Z")

</div>

While using the API and making a put request to:  
MYDISCOURSE/users/MYUSER?api\_key=MYSYSTEMAPIKEY&api\_username=system  
with a json payload of:  
{“username”:“helloworld”}  
I am receiving a response with a code of 200 and a body that indicates the username has not been changed.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 31, 2018, 10:50pm UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/2 "2018-08-31T22:50:38Z")

</div>

Try this endpoint instead:

```plaintext
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:

```plaintext
{"id":1,"username":"blake2"}

```

---

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [September 2, 2018, 9:32am UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/4 "2018-09-02T09:32:53Z")

</div>

I was wondering: is it safe to change the system username?

---

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [September 2, 2018, 2:21pm UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/5 "2018-09-02T14:21:25Z")

</div>

> [@Can I rename "system" user permanently?](https://meta.discourse.org/t/can-i-rename-system-user-permanently/14909/5):
>
> Do not change the system username, it is the unique identifier for the account.

> [@Can I rename "system" user permanently?](https://meta.discourse.org/t/can-i-rename-system-user-permanently/14909/16):
>
> It actually is configurable. An administrator can easily rename the system user via the configuration interface. The question is whether there is internal code that still refers to that user by id as indicated earlier in this thread, or if this is now fixed and it’s fine to rename that user.

Looks like this is not confirmed yet.

---

<div class="post-metadata">

### Author: ![jezra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jezra/32/105986_2.png) [@jezra](https://meta.discourse.org/u/jezra)
#### Post date: [September 4, 2018, 6:02pm UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/6 "2018-09-04T18:02:54Z")

</div>

Thank you @blake that was exactly what I needed. 🙂

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [April 24, 2021, 10:51am UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/7 "2021-04-24T10:51:26Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [May 24, 2021, 10:51am UTC](https://meta.discourse.org/t/how-does-one-change-a-username-via-the-api/96118/8 "2021-05-24T10:51:45Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
