# Update Email

## Description

This service is used to updatea partner email for the authenticated user.

***

## Request

### Restrictions

This service requires an authenticated user and can only be called after a successful partner login.

### Endpoint

```
PUT https://<server-url>/api/v4/partner/emails
```

### Parameters

| Parameter                                | Location       | Description                                                                        |
| ---------------------------------------- | -------------- | ---------------------------------------------------------------------------------- |
| `touchpoint`                             | Query / Header | The identifier for the touchpoint. Use `Thalamus-Touchpoint` for the header.       |
| `token`                                  | Query / Header | The authentication token for the API session. Use `Thalamus-Token` for the header. |
| <p> </p><p><code>email</code></p><p></p> | Query          | Email to be updated                                                                |

### Full URL Example

```
https://<server-url>/api/v4/partner/emails?email=amail@thalamus.corp&touchpoint=test&token=...
```

### Request Body

The request body must be a JSON object with the following fields:

| Field    | Type      | Required | Description                                                       |
| -------- | --------- | -------- | ----------------------------------------------------------------- |
| `email`  | `string`  | Yes      | New email                                                         |
| `active` | `boolean` | Yes      | <p>Activate or deactivate email to receive information</p><p></p> |

JSON

```
{  
   "email":"jhon.smith@thalamuscorp.com",
   "active": true

}
  
```

***

## Response

### ✅ Successful Response: `201 Created`

* HTTP Status Code: `201 Created`
* Body: A JSON object confirming the successful update of the email.

Example Response

JSON

```
{
    "context": {
        "links": [
            {
                "ref": "home",
                "href": "http://localhost:8080/thalamus/api/v4/people/home"
            },
            {
                "ref": "profile",
                "href": "http://localhost:8080/thalamus/api/v4/people/profile"
            },
            {
                "ref": "consumer",
                "href": "http://localhost:8080/thalamus/api/v4/people/consumer"
            }
        ],
        "activities": [],
        "lastInboxMessages": null,
        "simpleProfile": {
            "partyId": null,
            "firstname": null,
            "lastname": null,
            "email": "partenr02@mail.com",
            "shortName": null,
            "longName": null,
            "address": null,
            "me": false,
            "urlAvatar": ""
        }
    },
    "partner_email": {
        "email": "jhon.smith@thalamuscorp.com",
        "active": true
    }
}
```

### ❌ Unsuccessful Response: `400 Bad Request`

* HTTP Status Code: `400 Bad Request`
* Body: A JSON object containing details about the error.

Example Response

JSON

```
{
  "errors": {
    "partnerDataSource": "TouchpointCodeRequired",
    "partnerDataSource": "InvalidTouchpointCode"
  }
}


{
    "errors": {
        "partnerEmail": "EmailAlreadyExists",
        "execution.partnerEmail": "execution.partnerEmail: EmailAlreadyExists"
    }
}
```
