# Create marketing email via api issue

**URL:** <https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181>\
**Category:** APIs & Integrations\
**Tags:** email\
**Created:** [January 18, 2024, 11:23pm UTC](https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181 "2024-01-18T23:23:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DorL](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@DorL](https://community.hubspot.com/u/DorL)\
**Post date:** [January 18, 2024, 11:23pm UTC](https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181/1 "2024-01-18T23:23:28Z")

</div>

Hi,

I’m currently working on creating a marketing email using the following request:

POST /marketing-emails/v1/emails/

const body = {

name: ‘Test marketing email’,

subject: ‘My email subject’,

state: ‘AUTOMATED\_DRAFT’,

emailBody: `Hi You {{contact.firstname}}`,

templatePath: ‘@hubspot/email/dnd/welcome.html’

}

While the email is successfully created, I’ve encountered an issue where the email body remains the default template body instead of the custom body I included in the request.

Could you please advise on the necessary steps to resolve this issue?

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 19, 2024, 6:45am UTC](https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181/2 "2024-01-19T06:45:13Z")

</div>

Hi @DorL 👋

As per this [(Legacy) HubSpot API doc](https://legacydocs.hubspot.com/docs/methods/lists/marketing-email-overview), the “emailBody” parameter sets _“the main content of the email **within the ‘main email body’ module** ”_. As such, in your email template, you’ll need to make sure you’re using this “main email body” module. For example:

```lia-code-sample
<!--
 templateType: email
 isAvailableForNewContent: true
-->
<!doctype html>
<html>

...

 <body>
 {% content_attribute "email_body" %}
 The content you send via API as "emailBody" should appear here.
 {% end_content_attribute %}

...

 </body>
</html>

```

More information about the “Main email body” can be found [here](https://knowledge.hubspot.com/design-manager/use-default-modules-in-your-template#main-email-body).

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![DorL](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@DorL](https://community.hubspot.com/u/DorL)\
**Post date:** [January 19, 2024, 10:05am UTC](https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181/3 "2024-01-19T10:05:27Z")

</div>

Thank you [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811)

If I want to use a default drag-and-drop template, what should I do? (like welcome or simple templates)

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 20, 2024, 1:17am UTC](https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181/4 "2024-01-20T01:17:11Z")

</div>

Hi @DorL 👋

Just make sure you use 1 “Main Email Body” module in your email template. That should do the trick.

 ![Screenshot 2024-01-20 at 11.14.12.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/8/b81ae781b1a434de2a02927faccb2c88734445ce.png)

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![DorL](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@DorL](https://community.hubspot.com/u/DorL)\
**Post date:** [January 20, 2024, 3:09pm UTC](https://community.hubspot.com/t/create-marketing-email-via-api-issue/98181/5 "2024-01-20T15:09:59Z")

</div>

I’d like to share my overall objective and see if you can assist me.

I want to create a sequence (or a workflow if sequence isn’t possible) that, upon enrollment of a specific contact, triggers the automatic sending of a transactional email (or a marketing email if a transactional one isn’t possible). The email should contain dynamic content, such as the contact name and a link that varies from one contact to another.

I intend to achieve all of this exclusively through the API, involving the following steps:

1. Creation of an email template
2. Creation of the email itself
3. Creation of the sequence or workflow

I appreciate your assistance!
