# Create Email

## Description

This service is used to create a 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

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

### Parameters

You can pass the following authentication credentials as query parameters or HTTP headers.

| 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. |

### Full URL Example

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

### Request Body

| Field    | Type      | Required | Description                                                       |
| -------- | --------- | -------- | ----------------------------------------------------------------- |
| `email`  | `string`  | Yes      | Email to whom to report datasource processes.                     |
| `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 creation of the datasource.

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"
    }
}
```
