APIs & Integrations

JayL
Participant

Creating a marketing email with the API

SOLVE

Hello,

 

Using the API I need to be able to create an email (or possibly update an email), meaning content & subject. Select recipients, then schedule the emails.

 

I could potentially select recipients for emails, and then update the content of existing emails. But then I would need to schedule them.

 

Reading this from last year it looks like much of this is not possible. Is that correct? Has anything changed? Are there plans?

https://community.hubspot.com/t5/APIs-Integrations/Marketing-Email-API-Questions/m-p/304225#M28687

 

Thanks,
Jay

0 Upvotes
1 Accepted solution
Willson
Solution
HubSpot Employee
HubSpot Employee

Creating a marketing email with the API

SOLVE

Hey @JayL 

 

The parameters that can be passed when creating the Marketing Emails can be found in the Overview here.


As an example, you can create the email with the following payload:

Request URL:
POST https://api.hubapi.com/marketing-emails/v1/emails?hapikey={{hapikey}}

{
		"name": "My first API marketing email!",
		"subject": "Sample subject line",
		"fromName": "Sample Author",
		"campaign": "eeeeeeee-eeee-eeee-eeee",
		"CampaignName": "Sample - My first inbound campaign in HubSpot",
		"emailBody": "Email Body"
	}

In this case, if you wish to pass HTML, I believe you will have to format the HTML to be valid in the JSON payload.

 

It's worth noting that in the above payload, I provide an email body. When accessing the email via the UI, I will be asked to choose a template that the email will be based off of, then, my content will be added to the template in the Email Body module. 

 

I hope this helps!

Product Manager @ HubSpot

View solution in original post

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Creating a marketing email with the API

SOLVE

Hey @JayL 

 

I can confirm that it is indeed possible to create and send emails via our APIs. As my colleague, Wendy mentioned in this post, we can create emails using our Create a new marketing email API.

With regards to adding recipients and sending, this is handled through the use of our Single-send API. It's important to note here though that, this method is used to send an email designed and maintained in the Marketing Hub's email tool - therefore they do not work directly together.

 

The use of the Single-send API also requires the access to our Transactional Email add-on which is an additional cost to access, you can find more details on this here

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
JayL
Participant

Creating a marketing email with the API

SOLVE

Hi @Willson ,

 

Thanks for the reply.

 

The only 2 vars in the post example are name & subject. What am I missing, I don't see how to add the email body, and presumably other email details. I'm working on putting together customized content that I would need to upload as HTML into an email.

 

Thanks again,

Jay

0 Upvotes
Willson
Solution
HubSpot Employee
HubSpot Employee

Creating a marketing email with the API

SOLVE

Hey @JayL 

 

The parameters that can be passed when creating the Marketing Emails can be found in the Overview here.


As an example, you can create the email with the following payload:

Request URL:
POST https://api.hubapi.com/marketing-emails/v1/emails?hapikey={{hapikey}}

{
		"name": "My first API marketing email!",
		"subject": "Sample subject line",
		"fromName": "Sample Author",
		"campaign": "eeeeeeee-eeee-eeee-eeee",
		"CampaignName": "Sample - My first inbound campaign in HubSpot",
		"emailBody": "Email Body"
	}

In this case, if you wish to pass HTML, I believe you will have to format the HTML to be valid in the JSON payload.

 

It's worth noting that in the above payload, I provide an email body. When accessing the email via the UI, I will be asked to choose a template that the email will be based off of, then, my content will be added to the template in the Email Body module. 

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes