XM

Update Username

Path:

PATCH /user/{userId}/username

This endpoint enables users the flexibility to update their Username (email address), easily from the UI. The system-generated user ID must be passed in the request path, and the email address in the request body. In response, all the user details are retrieved to rebuild the profile.

To update the other attributes of the user profile such as email, name, phone number, etc, the Update User endpoint is recommended.

Headers

Content-Type application/json

Authorization: {AuthToken}

x-site-context: {site-context}

Consumes

  • application/json

Produces

  • application/json

Parameters

Type: Path

Name: System user ID (user._Id)

Required: true

Type: Body

Name: prior and new email addresses

Required: true

Sample Request

Path:

https://{baseurl}/user/5e97947d3cb8553c0e43d87f/username

Body:

{
"oldUsername": "[email protected]",
"newUsername": "[email protected]"
}

Response

HTTP Code : 200 Message : OK

Description: You will see this message when the Username is successfully updated.

Sample

{
"_id": "5e97947d3cb8553c0e43d87f",
"isActive": {
"status": true
},
"registrationDate": "2020-04-15T22:34:22.429Z",
"expiryDate": "2070-04-15T22:34:22.429Z",
"roles": [
"5de1646f8c6352091d944f1c"
],
"name": {
"first": "John",
"middle": "A",
"last": "Doe"
},
"phone": [
{
"_id": "5e97947d3cb8553c0e43d880",
"number": "123456789",
"countryCode": "+1",
"extension": "1234",
"kind": "mobile",
"id": "5e97947d3cb8553c0e43d880"
}
],
"email": "[email protected]",
"extra": {
"dob": "03-19-1993"
},
"registrationSite": "abcde.com",
"account": "5e97947d3cb8553c0e43d87e",
"userId": 90,
"address": [],
"provider": [
{
"registrationDate": "2020-04-15T22:34:22.429Z",
"isActive": true,
"_id": "5e97947d3cb8553c0e43d881",
"name": "LOCAL",
"lastLoginDate": "2020-04-16T04:28:33.560Z",
"id": "5e97947d3cb8553c0e43d881"
}
],
"createdAt": "2020-04-15T23:10:53.773Z",
"updatedAt": "2020-04-16T04:38:51.187Z",
"__v": 0
}

HTTP Code : 404 Message : Not Found

Description: You will see this message when the system user ID is incorrect.

Sample

{
"code": "USER_NOT_FOUND",
"message": "User not found."
}

Changelog

  • Last updated - July 2020