# PUT /u/{username}.json does not change the email

**URL:** https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272
**Category:** Bug
**Tags:** rest-api
**Created:** [July 30, 2023, 3:58pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272 "2023-07-30T15:58:45Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![xbd](https://avatars.discourse-cdn.com/v4/letter/x/b5e925/32.png) [@xbd](https://meta.discourse.org/u/xbd)
#### Post date: [July 30, 2023, 3:58pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/1 "2023-07-30T15:58:45Z")

</div>

According to the Discourse API Docs ([Discourse API Docs](https://docs.discourse.org/#tag/Users/operation/updateUser)), it should be possible to change the email via the referenced endpoint.

1. Use this API-Endpoint: PUT /u/{username}.json
2. Use this request body:

```plaintext
{
    "Name": "Test Name",
    "Email": "test@test.com"
}

```

1. Received 200 OK. Name will change, Email not.

The response does not contain the “email” field.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 30, 2023, 4:17pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/2 "2023-07-30T16:17:52Z")

</div>

I recommend that you [Reverse engineer the Discourse API](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576) and see what api call to use.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [July 31, 2023, 9:51am UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/3 "2023-07-31T09:51:55Z")

</div>

Hi xbd,

According to the documentation, changing the email uses this endpoint: `/u/{username}/preferences/email.json`: [https://docs.discourse.org/#tag/Users/operation/updateEmail](https://docs.discourse.org/#tag/Users/operation/updateEmail)

However, it will send a confirmation link to the email address to be manually approved by the user. Until then, the email won’t be changed.

---

<div class="post-metadata">

### Author: ![xbd](https://avatars.discourse-cdn.com/v4/letter/x/b5e925/32.png) [@xbd](https://meta.discourse.org/u/xbd)
#### Post date: [July 31, 2023, 3:27pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/4 "2023-07-31T15:27:48Z")

</div>

Thank you for your assistance. Maybe helpful to remove the email property from the PUT /u/{username.json} in the documentation. Could save time spent on debugging ;-).

The thing with the confirmation mail: I read about it on another topic. I don’t get the point. Just in case, Discourse is an application of many others in the project and the authentication of users is handled by a custom-made auth server (like my case). The auth server handles email confirmation. The applications should just do, what the auth server says. This is in my opinion the normal way. Otherwise it comes with multiple confirmation mails, different datasets…

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [July 31, 2023, 3:33pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/5 "2023-07-31T15:33:42Z")

</div>

> [@xbd](#):
>
> Thank you for your assistance. Maybe helpful to remove the email property from the PUT /u/{username.json} in the documentation. Could save time spent on debugging ;-).

Thank you for raising this. This is weird indeed. It may be a remnant of a past era. I’ll get some info and update the doc if needed. 👍

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 31, 2023, 4:44pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/6 "2023-07-31T16:44:08Z")

</div>

> [@xbd](#):
>
> The auth server handles email confirmation. The applications should just do, what the auth server says.

Does the `auth overrides email` admin setting help with this?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 31, 2023, 11:45pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/7 "2023-07-31T23:45:56Z")

</div>

> [@xbd](#):
>
> authentication of users is handled by a custom-made auth server (like my case). The auth server handles email confirmation.

Then you need to configure it to tell discourse that the email address has been validated and not update email on the API, but on your authentication server.

---

<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 10, 2023, 9:36pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/8 "2023-08-10T21:36:58Z")

</div>

> [@xbd](#):
>
> Maybe helpful to remove the email property from the PUT /u/{username.json} in the documentation. Could save time spent on debugging ;-).

Thanks again for bringing this up and sorry about the time spent debugging. The API docs have been updated.

---

<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 10, 2023, 9:37pm UTC](https://meta.discourse.org/t/put-u-username-json-does-not-change-the-email/273272/9 "2023-08-10T21:37:03Z")

</div>


