Change User Email Address

Last modified on August 23, 2023 at 1:12 pm

Overview

To reset a user’s email address, you can send an HTTP PUT request to the user’s URL with a JSON object containing an email property with the new email address for the user. On success, the server will respond with an HTTP 201 status.

Note that you are not limited to updating one property at a time; all fields may be updated in a single request. All fields not specified will retain their value.

Example

This example shows the request-response sequence when changing a user’s email address.

Request
PUT /dc/api/v5/users/8d7a97a97a92efd18dcbc12876a4510e HTTP/1.1
Host: api.digitalchalk.com
Content-type: application/json
Accept: application/json

{
	"email": "suarezd@exampleorg.com"
}
Response
HTTP/1.1 204 No Content
Content-length: 0

Failure Cases

Below is a list of the most common failure scenarios your code should be prepared to handle. This list is not exhaustive.

Email address validation

In the following example, an attempt is made to set the user’s email address to a value which does not conform to email address format. The validation step will reject the email, return a response with an HTTP 400 status, and provide a description of the problem in the fieldErrors property.

Request
PUT /dc/api/v5/users/8d7a97a97a92efd18dcbc12876a4510e HTTP/1.1
Host: api.digitalchalk.com
Content-type: application/json
Accept: application/json

{
	"email": "cruzt at yahoo dot com", 
}
Response
HTTP/1.1 400 Bad Request
Content-type: application/json
Content-length: 210

{
	"fieldErrors" : {
		"email" : "Invalid email address"
	}
}

Reference