# Email API From and To

**URL:** <https://community.hubspot.com/t/email-api-from-and-to/86914>\
**Category:** APIs & Integrations\
**Tags:** free\
**Created:** [August 7, 2023, 10:54am UTC](https://community.hubspot.com/t/email-api-from-and-to/86914 "2023-08-07T10:54:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSandeep](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@SSandeep](https://community.hubspot.com/u/SSandeep)\
**Post date:** [August 7, 2023, 10:54am UTC](https://community.hubspot.com/t/email-api-from-and-to/86914/1 "2023-08-07T10:54:49Z")

</div>

Mails logged using [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/email) is not logging To email address even when adding in hs\_email\_headers. From is shown using hubspot\_owner\_id.

---

<div class="post-metadata">

**Author:** ![coldrickjack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/coldrickjack/32/6684_2.png) [@coldrickjack](https://community.hubspot.com/u/coldrickjack)\
**Post date:** [August 7, 2023, 11:35am UTC](https://community.hubspot.com/t/email-api-from-and-to/86914/2 "2023-08-07T11:35:34Z")

</div>

Hi @SSandeep,

You also need to ensure you are passing through an associations object in your request to correctly associate the contact and the email. The “hs\_email\_headers” on their own will not automatically log an email to a contact. See request below for reference:

```lia-code-sample
POST https://api.hubapi.com/crm/v3/objects/emails
BODY:
{
 "properties": {
 "hs_timestamp": "2019-10-30T03:30:17.883Z",
 "hubspot_owner_id": "1147024111",
 "hs_email_direction": "EMAIL",
 "hs_email_status": "SENT",
 "hs_email_subject": "Example Email created via API",
 "hs_email_text": "This email was created using the HubSpot APIs",
 "hs_email_headers": "{\"from\":{\"email\":\"brucebanner@avengers.com\",\"firstName\":\"Bruce\",\"lastName\":\"Banner\"},\"sender\":{\"email\":\"brucebanner@avengers.com\",\"firstName\":\"Peter\",\"lastName\":\"Parker\"},\"to\":[{\"email\":\"Peter+Parker<peterparker@marvel.com>\",\"firstName\":\"Peter\",\"lastName\":\"Parker\"}],\"cc\":[],\"bcc\":[]}"
 },
 "associations": [
 {
 "to": {
 "id": "101"
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": "198"
 }
 ]
 }
 ]
}

RESPONSE: 
{
 "id": "19361148152",
 "properties": {
 "hs_all_owner_ids": "1147024111",
 "hs_body_preview": "This email was created using the HubSpot APIs",
 "hs_body_preview_html": "This email was created using the HubSpot APIs",
 "hs_body_preview_is_truncated": "false",
 "hs_createdate": "2023-08-07T11:31:10.860Z",
 "hs_email_attached_video_opened": "false",
 "hs_email_attached_video_watched": "false",
 "hs_email_direction": "EMAIL",
 "hs_email_from_email": "brucebanner@avengers.com",
 "hs_email_from_firstname": "Bruce",
 "hs_email_from_lastname": "Banner",
 "hs_email_headers": "{\"from\":{\"email\":\"brucebanner@avengers.com\",\"firstName\":\"Bruce\",\"lastName\":\"Banner\"},\"to\":[{\"email\":\"Peter+Parker<peterparker@marvel.com>\",\"firstName\":\"Peter\",\"lastName\":\"Parker\"}],\"cc\":[],\"bcc\":[],\"sender\":{\"email\":\"brucebanner@avengers.com\",\"firstName\":\"Peter\",\"lastName\":\"Parker\"}}",
 "hs_email_sender_email": "brucebanner@avengers.com",
 "hs_email_sender_firstname": "Peter",
 "hs_email_sender_lastname": "Parker",
 "hs_email_status": "SENT",
 "hs_email_subject": "Example Email created via API",
 "hs_email_text": "This email was created using the HubSpot APIs",
 "hs_email_to_email": "Peter+Parker<peterparker@marvel.com>",
 "hs_email_to_firstname": "Peter",
 "hs_email_to_lastname": "Parker",
 "hs_lastmodifieddate": "2023-08-07T11:31:10.860Z",
 "hs_object_id": "19361148152",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "1914406",
 "hs_timestamp": "2019-10-30T03:30:17.883Z",
 "hs_user_ids_of_all_owners": "4592290",
 "hubspot_owner_assigneddate": "2023-08-07T11:31:10.860Z",
 "hubspot_owner_id": "1147024111"
 },
 "createdAt": "2023-08-07T11:31:10.860Z",
 "updatedAt": "2023-08-07T11:31:10.860Z",
 "arc

```

Email is successfully logged in the CRM:

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/d/1d404c29d557fbdc60fa064dc8be12ba378bc708.png)

I hope this helps!
