Why do the emails I created via API have newlines stripped?

When I create an email using the POST https://api.hubapi.com/crm/v3/objects/email endpoint with

{
 "properties": {
 "hs_timestamp": "2024-08-21T12:35:00.000Z",
 "hubspot_owner_id": 406511315,
 "hs_email_direction": "EMAIL",
 "hs_email_subject": "Re: Hubspot API Test",
 "hs_email_text": "Fred,\r\nThe renewal quote you've sent for Standard Plan is $2,797/year for a 2-year\r\ncommitment.\r\n\r\nStandard Plan on the website is $25/month/user for a 1-year commitment.\r\n\r\n",
 "hs_email_status": "SENT",
 "hs_email_headers": "{\"from\":{\"email\":\" graeme.harker@normanandsons.com \",\"firstName\":\"Graeme\",\"lastName\":\"Harker\"},\"to\":[{\"email\":\" fred.bloggs@bloggs.com \",\"firstName\":\"Fred\",\"lastName\":\"Bloggs\"}],\"cc\":[],\"bcc\":[]}"
 },
 "associations": [
 {
 "to": {
 "id": "8283"
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 198
 }
 ]
 }
 ]
}

The email appears in Hubspot with the newlines stipped

but if I click on the email in Hubspot (as if to edit it) I can see the newlines.

What am I doing wrong?

Hey @graemeh,

I was experiencing the same thing. I noticed using “<br>” worked a charm. For instance using the below:

POST https://api.hubapi.com/crm/v3/objects/email
BODY
{
 "properties": {
 "hs_timestamp": "2024-08-29T15:11:00.000Z",
 "hubspot_owner_id": "1204524575",
 "hs_email_direction": "EMAIL",
 "hs_email_status": "SENT",
 "hs_email_subject": "Re: Hubspot API Test",
 "hs_email_text": "Fred,<br>The renewal quote you've sent for Standard Plan is $2,797/year for a 2-year<br>commitment.<br><br>Standard Plan on the website is $25/month/user for a 1-year commitment.<br><br>",
 "hs_email_headers": "{\"from\":{\"email\":\" graeme.harker@normanandsons.com \",\"firstName\":\"Graeme\",\"lastName\":\"Harker\"},\"to\":[{\"email\":\" fred.bloggs@bloggs.com \",\"firstName\":\"Fred\",\"lastName\":\"Bloggs\"}],\"cc\":[],\"bcc\":[]}"
 },
 "associations": [
 {
 "to": {
 "id": 28333023942
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 198
 }
 ]
 }
 ]
}

Results in this being output on the contacts activity timeline:

It seems HubSpot prefers HTML tags being passed through, another example:

POST https://api.hubapi.com/crm/v3/objects/email
BODY
{
 "properties": {
 "hs_timestamp": "2024-08-29T15:11:00.000Z",
 "hubspot_owner_id": "1204524575",
 "hs_email_direction": "EMAIL",
 "hs_email_status": "SENT",
 "hs_email_subject": "Re: Hubspot API Test",
 "hs_email_text": "<h1 style='color:red'>Fred,</h1><br>The renewal <i>quote</i> you've sent for Standard Plan is $2,797/year for a 2-year<br>commitment.<br><br>Standard Plan on the website is $25/month/user for a 1-year commitment.<br><br>",
 "hs_email_headers": "{\"from\":{\"email\":\" graeme.harker@normanandsons.com \",\"firstName\":\"Graeme\",\"lastName\":\"Harker\"},\"to\":[{\"email\":\" fred.bloggs@bloggs.com \",\"firstName\":\"Fred\",\"lastName\":\"Bloggs\"}],\"cc\":[],\"bcc\":[]}"
 },
 "associations": [
 {
 "to": {
 "id": 28333023942
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 198
 }
 ]
 }
 ]
}

RESULT:

I hope this helps!

Jack

Yes, thanks. That fixed it.