So I have a script that I’m running to create dataframe table visualizations that I want to somehow place in a cloned marketing email draft, whether as images or some sort of table. Is this something that is possible through the marketing email api? I’m not sure what formatting is accepted when updating the body of a marketing email as there isn’t too much documentation
Hey, @MH1279
Thanks for your question.
Regarding your code, please share what you’ve already tried, even if it didn’t work as expected. This can be helpful when asking the community for help.
@Anton @tjoyce @Phil_Vallender have you tried anything similar? Or do you have any suggestions on other ways @MH1279 might approach this challenge?
Thank you for taking a look! — Jaycee
I was checking to see if it’s possible to insert a python dataframe or visuals from python directly into a marketing email draft through the API
That’s a good question to revisit in 2025, because the Marketing Email API has expanded since 2023.
Right now, you still can’t insert a live dataframe or Python object directly into a HubSpot email draft. The API accepts HTML for the email body, so your safest path is to render your dataframe or visualization to an image (PNG/JPEG), upload it to HubSpot’s File Manager through the Files API, and then reference that hosted file in your email body HTML. Tables can also be hard-coded as HTML, but not passed in as Python objects.
If your goal is dynamic data insertion, in 2025 HubSpot’s custom modules and CMS Hub email templates give you more flexibility you can design a custom module with a placeholder for images or tables and then update that module content programmatically via API before sending. This way you don’t fight against formatting limits of the email editor.
A clarifying point: are you hoping these visualizations refresh automatically in recurring sends, or are you just trying to automate populating them once into a draft? That choice will change whether you lean on pre-generated static images versus building a reusable module fed by new files.