Skip Navigation
Expand
Working with contact email addresses through the REST API
Answer ID 10785   |   Last Review Date 03/19/2019

How do I set, update or remove a contact's email address using the REST API?

Environment:

Oracle B2C Service, all supported versions

Resolution:

A contact record may have multiple email addresses associated to it, as primary or secondary email addresses. Below is a sample REST request that creates a contact having three email addresses: one primary and two alternate email addresses:

Endpoint: https://<your_site>.custhelp.com/services/rest/connect/latest/contacts
HTTP Method: POST
Header: OSvC-CREST-Application-Context: any_value (Only required for Connect v1.4)
JSON Payload:

{
  "name": {
    "first": "John",
    "last": "Doe"
  },
  "emails": [{
      "address": "primary@oracle.com.invalid",
      "addressType": {
          "id": 0
      }
  },
  {
      "address": "alternate1@oracle.com.invalid",
      "addressType": {
          "id": 1
      }
  },
  {
      "address": "alternate2@oracle.com.invalid",
      "addressType": {
          "id": 2
      }
  }]
}​​​​​​

In order to update a contact's email address, an UPDATE request needs to be sent to the specific email address resource. For example:

Endpoint: https://<your_site>.custhelp.com/services/rest/connect/latest/contacts/<contact_id>/emails/0
HTTP Method: POST
Header: OSvC-CREST-Application-Context: any_value (Only required for Connect v1.4)
Header: X-HTTP-Method-Override: PATCH
JSON Payload:

{
    "address": "primary_new@oracle.com.invalid"
}

Note: The PATCH request is expected to return an empty response. For more information see
Answer 8394: Receiving no response when using PATCH

To remove (nullify) a contact's email address, a DELETE request needs to be sent to the resource corresponding to the email address:

Endpoint: https://<your_site>.custhelp.com/services/rest/connect/latest/contacts/<contact_id>/emails/0
HTTP Method: DELETE
Header: OSvC-CREST-Application-Context: any_value (Only required for Connect v1.4)

Note: The DELETE request is also expected to return an empty response.
Note: The ID that follows the /emails/ in the URL corresponds to the type of email address. 0 is primary, 1 is the first alternate, 2 is the second alternate.

Additional information can be found in the REST API documentation:
Answer 5169: Technical Documentation and Sample Code