Api - Problem to set property hs_email_headers on incoming Email Object

Hi,

I try to create an incoming email with api call.

POST https://api.hubapi.com/crm/v3/objects/emails

Body :

{
 "properties": {
 "hubspot_owner_id": "63590768",
 "hs_email_text": "bodyContent",
 "hs_email_subject": "test hs_email_direction incoming 1",
 "hs_email_direction": "INCOMING_EMAIL",
 "hs_timestamp": 1681894200000,
 "hs_email_status": "SENT"
 },
 "hs_email_headers": {
 "from": {
 "email": "contact1@company1.com"
 },
 "to": [
 {
 "email": "contact2@company2.com"
 },
 {
 "email": "myself@mycompany.com"
 }
 ],
 "cc": [
 {
 "email": "contact3@company3.com"
 }
 ]
 }
}

Response is 201

But when looking on hubspot CRM UI

hs_email_headers have been ignored.

For an outgoing email same payload with only difference on :

“hs_email_direction”: “EMAIL”

The header part in hubspot CRM UI is right

Could you helpme on this one as I surely missing something?

Regards

Tibo

Hey, @tbalthazard. Thanks for flagging this. I’ll take your example and to reproduce the issue on my end.

Best,

Jaycee

Hello, were you able to reproduce and correct the problem?

Regards

Tibo

Hi,

I am facing the exact same issue. Do you have an update on this issue?

Hey @AJoshi95, thank you for posting in our Community.

Could you please specify what you are currently experiencing? Since this is not a new post, the more information, screenshots, and details you can provide, the better I can advise on the next steps.

Kindly,

Pam

Hey @PamCotton,

Thanks for your response.

I am using Ruby gem hubspot-api-client for my integration. (I am pretty new to Hubspot integration as well as Ruby and Ruby on Rails.)

Below is a code snippet where I am updating the Contact, Company and Email objects. The Contact, Company and Email objects get created successfully, all the associations also get created. The only issue is the Email headers not showing correctly.

 def save_to_crm 
 contact_association = []
 if company_name?
 company_body = {associations:[], properties:{"name":company_name, "domain": company_website}}
 company_api_response = crm_client.crm.companies.basic_api.create(body: company_body)
 if company_api_response.id
 contact_association = [{"types":[{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId":1}], "to":{"id":company_api_response.id}}]
 end
 end
 contact_body = {associations:contact_association, properties:{"firstname": first_name, "lastname": last_name, "email": email_address, "company": company_name}}
 contact_api_response = crm_client.crm.contacts.basic_api.create(body: contact_body)
 if contact_api_response.id
 email_association = [{"types":[{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId":198}], "to":{"id":contact_api_response.id}}]
 if company_api_response.id
 email_association[1] = {"types":[{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId":186}], "to":{"id":company_api_response.id}}
 end
 email_header_hash = {"from":{"email":email_address, "firstName":first_name, "lastName":last_name}, "sender":{"email":email_address, "firstName":first_name,"lastName":last_name},"to":{"email":"info@mydomain.com", "firstName":"Info", "lastName":"MyDomain.com" }, "cc":[], "bcc":[]}
 email_body = {associations: email_association, properties:{"hs_email_direction": "INCOMING_EMAIL", "hs_email_subject": "Website Contact Us Page - Contact", "hs_email_text": message, "hs_timestamp": Time.now.utc.iso8601, "hs_email_headers": email_header_hash.to_json}}
 email_api_response = crm_client.crm.objects.emails.basic_api.create(body: email_body)
 end
 end

 def crm_client
 return Hubspot::Client.new(access_token: Rails.application.credentials.dig(:hubspot, :API_KEY))
 end

The form used to capture the data:

Resulting Company record:

Notice the data highlighted in yellow.

Company, Contact and associations updated correctly but the email header details are blank.

I want to invite our top experts @Anton and @DanielSanchez do you have any recommendations?

Thank you,

Pam