# How can I update users via API using the user id (not username)?

**URL:** https://meta.discourse.org/t/how-can-i-update-users-via-api-using-the-user-id-not-username/170203
**Category:** Development
**Tags:** rest-api
**Created:** [November 15, 2020, 5:06pm UTC](https://meta.discourse.org/t/how-can-i-update-users-via-api-using-the-user-id-not-username/170203 "2020-11-15T17:06:09Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [November 16, 2020, 10:13pm UTC](https://meta.discourse.org/t/how-can-i-update-users-via-api-using-the-user-id-not-username/170203/2 "2020-11-16T22:13:01Z")

</div>

For now I think your best option is to make two api requests. One to [fetch the user by id](https://docs.discourse.org/#tag/Users/paths/~1admin~1users~1%7Bid%7D.json/get) in order to get the username, and the second request to update by username.

There is an option to update a user by `external_id` but I don’t think this can be used without single-sign-on enabled, but this way Discourse stores the id of the user of your application instead of the other way around.

---

_[View the full topic](https://meta.discourse.org/t/how-can-i-update-users-via-api-using-the-user-id-not-username/170203)._
