API v3: /marketing/v3/emails : Sending one to one customisable email to contacts

Hi team,

We are partnering with a third-party company that generates HTML email content, and we would like to send this generated HTML directly through HubSpot using the Marketing API.

So far, the only approach I’ve found requires passing the html_body via widgets while creating a template, and then using customProperties to populate those variables when sending the email.

Is there a way to send a complete HTML email directly instead of just able to customise body of the HTML.

Hi @AShah771 thanks for reaching out to the Community on this regard ! As of today, there does not seem to be an endpoint that accepts a fully self-contained HTML email body and sends it without going through a template + widget. Some solutions you could implement are:

  • Create a coded marketing email template with the required HubL and one main body widget.
  • Send the third‑party HTML into that widget via the content.widgets object when you create/update the email through the Marketing Email API.

I would also like to add some API experts to the conversation, @Christensen @d-lupo @Shubham_Sharma do you have any other suggestions to help @AShah771 send a complete HTML email directly through the API instead of customizing the body of the HTML? - Josefina, Community Moderator

I tried doing this I’m trying to inject customProperties into the <head> section of an HTML + HubL template to map with my html content.However, according to the documentation, the template is compiled first, and the customProperties variables are resolved only at runtime. When I tried adding a variable like custom.var1 inside the <head> and sent an email via Single Send, the content was moved to the email body instead.
I have two questions:
1. Why does this behavior occur?
How is the variable still being resolved ends up in the body instead of the head?
2. What is the recommended workaround to support recipient-based styling given this limitation?

Hey @AShah771 - thanks for posting in the Community!
I’d like to tag in some Community experts here to see if they have any insight for us that may answer your questions! @Bryantworks, @ChrisoKlepke, and @Syeda_Fatima - any thoughts for @AShah771 ?
Shane, Senior Community Moderator

Hi all, for anyone reading this in the future:
I was able to resolve the issue by treating all the attributes and content of a tag as variables. For example:

<body {{custom.body_attribute}}> {{custom.body_content}} </body>

Then, while using the v4 Single Send API, I passed the corresponding values through customProperties.