Update username with Okta API

I need to update the username value of a user using the API. Searching on the web I found this link:

It takes me to the API documentation, which have this method

However, this method is not on the Postman API collection of users and I cannot do the update. I also tried with the API Call “Update App Credentials for Assigned User” of the Apps collection, but its not working.

Any help is appreciated.

use this as an example - https://developer.okta.com/docs/reference/api/users/?_ga=2.13663796.2030790437.1601820794-1034218225.1579645140#update-profile-with-id

Hi,

Even though that endpoint it is on the documentation, its not on the Users API Collection, so I cannot call it.

What stops you from creating a Postman entry for it?

Hi @evitoria,

As suggested in https://developer.okta.com/docs/reference/api/users/#update-current-user-s-profile, you could use POST /Users/{userId} to do partial update to the user profile.

An example to update only the username would be to do:

POST https://{oktaOrg}/api/v1/users/{userId}
{
“profile”: {
“login”: “username_updated@mailinator.com
}
}

CURL command:
curl --location --request POST ‘https://dev-634981.oktapreview.com/api/v1/users/00ug93psg5p7tFIhj0h7
–header ‘Accept: application/json’
–header ‘Content-Type: application/json’
–header ‘Authorization: SSWS {apiToken}’
–data-raw ‘{
“profile”: {
“login”: “username_updated@mailinator.com
}
}’

If you would like to use PUT /Users/{userId} as suggested in https://developer.okta.com/docs/reference/api/users/#update-user, all profile properties must be specified. Any property not specified in the request is deleted.

Hi,

Thanks @gpadma and @phi1ipp. You were right, I added the request manually in Postman and was able to do the change.

Could someone elaborate on how to perform this request in Postman?

So i want to use the update user API to update multiple users on a custom attribute and populate with a new value. I am ok with using postman for lifecycle operations and rockstar to get the exports i need but i can’t seem to be able to build this request in Postman.

Hi @moutsos, your postman request should look something like this:

Let me know if that helps, thanks!

Hi @Cale ,

I am using postman to add a new user to Okta.

I am not getting any response.
Can you please check the attached screenshots and let me know if there is anything I am missing ?

Appreciate your help.


Thanks
Ajit

Hi @ajitnayak . The Authorization header value should be in the following format:

SSWS 00Thqxgk...

2 Likes

Hello, what if I need to change the status of the user to password_rest to trigger activation email? Do you have an idea how to form the body?

I tried
{
“profile”: {
“status": “PASSWORD_RESET”
}
}

but encountered an error since status is not under profile. Hope you can help thanks!

There’s a dedicated endpoint to trigger password resets: https://developer.okta.com/docs/reference/api/users/#reset-password

As an aside, its a good idea to create a new post if the thread you are looking to comment on has already been closed out with a solution. That way more people see your new thread so they can help you out!