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:
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:
I hope this helps!
