Create automated email thru APIs

Hey there HubSpot community!

I’m curious to know if any of you have successfully created a non-transactional and automated email through the HubSpot API. We’ve been exploring this option, but so far, we’ve only come across a simple send API format for transactional emails.

As much as we appreciate the functionality of transactional emails, we’re eager to learn more about creating non-transactional automated emails. Have any of you attempted this? If so, what was your experience like?

We’d love to hear any insights, tips, or tricks that you might have to share on this topic. Let’s start a conversation and help each other out!

Hey, @Roynal :waving_hand: Thanks for starting the conversation.

To confirm, you are referring to Automated Emails for use in Workflows, correct? If so, the documentation doesn’t give many clues on what is possible for this specific type of marketing email.

Here’s what I found:

Here’s a quick test I did using Postman:

  • I made an in-app automated email as a draft. This gives me something to compare with later

  • My request
    POST https://api.hubapi.com/marketing-emails/v1/emails​

    Request body

    {
     "name": "Test Email2",
     "subject": "Test Subject",
     "emailType": "AUTOMATED_EMAIL",
     "state": "AUTOMATED_DRAFT"
    }​
    
  • Response + in-app screenshot of successful draft

    {
     "ab": false,
     "abHoursToWait": 4,
     "abSampleSizeDefault": null,
     "abSamplingDefault": null,
     "abSuccessMetric": null,
     "abTestPercentage": 50,
     "abVariation": false,
     "absoluteUrl": "http://22245342.hs-sites.com/-temporary-slug-b0a693ee-2aa9-419e-ae26-cdd97601e014",
     "allEmailCampaignIds": [],
     "analyticsPageId": "112774554265",
     "analyticsPageType": "email",
     "archivedAt": 0,
     "archivedInDashboard": false,
     "audienceAccess": "PUBLIC",
     "blogRssSettings": null,
     "canSpamSettingsId": 77854541938,
     "categoryId": 2,
     "contentAccessRuleIds": [],
     "contentAccessRuleTypes": [],
     "contentTypeCategory": 2,
     "createPage": false,
     "created": 1682454082164,
     "createdById": 10233975,
     "currentState": "AUTOMATED_DRAFT",
     "currentlyPublished": false,
     "customReplyTo": "",
     "customReplyToEnabled": false,
     "domain": "",
     "emailBody": "{% content_attribute \"email_body\" %}{{ default_email_body }}{% end_content_attribute %}",
     "emailNote": "",
     "emailTemplateMode": "DESIGN_MANAGER",
     "emailType": "AUTOMATED_EMAIL",
     "feedbackSurveyId": null,
     "flexAreas": {},
     "freezeDate": 1682454082164,
     "fromName": "",
     "hasContentAccessRules": false,
     "htmlTitle": "",
     "id": 112774554265,
     "isCreatedFomSandboxSync": false,
     "isGraymailSuppressionEnabled": false,
     "isPublished": false,
     "isRecipientFatigueSuppressionEnabled": null,
     "language": "en",
     "layoutSections": {},
     "liveDomain": "22245342.hs-sites.com",
     "mailingListsExcluded": [],
     "mailingListsIncluded": [],
     "maxRssEntries": 5,
     "metaDescription": "",
     "name": "Test Email2",
     "pageExpiryEnabled": false,
     "pageRedirected": false,
     "pastMabExperimentIds": [],
     "portalId": 22245342,
     "previewKey": "Iotvmnho",
     "processingStatus": "",
     "publishDate": 1682454082216,
     "publishImmediately": true,
     "publishedUrl": "",
     "replyTo": "",
     "resolvedDomain": "22245342.hs-sites.com",
     "rssEmailByText": "By",
     "rssEmailClickThroughText": "Read more »",
     "rssEmailCommentText": "Comment »",
     "rssEmailEntryTemplateEnabled": false,
     "rssEmailImageMaxWidth": 0,
     "rssEmailUrl": "",
     "sections": {},
     "securityState": "NONE",
     "slug": "-temporary-slug-b0a693ee-2aa9-419e-ae26-cdd97601e014",
     "smartEmailFields": null,
     "state": "AUTOMATED_DRAFT",
     "styleSettings": null,
     "subcategory": "batch",
     "subject": "Test Subject",
     "subscription": 52324090,
     "subscriptionName": "Cat email",
     "teamPerms": [],
     "templatePath": "",
     "transactional": false,
     "translations": {},
     "unpublishedAt": 0,
     "updated": 1682454082164,
     "updatedById": 10233975,
     "url": "http://22245342.hs-sites.com/-temporary-slug-b0a693ee-2aa9-419e-ae26-cdd97601e014",
     "useRssHeadlineAsSubject": false,
     "userPerms": [],
     "vidsExcluded": [],
     "vidsIncluded": [],
     "widgets": {}
    }​
    

Things I noticed:

  • If you don’t define a template in the request body, you’ll be asked to choose one when you go in-app to edit or publish the email
  • You cannot publish or send marketing emails via these endpoints

I hope this helps get you moving forward! — Jaycee

This seems very detailed. We will check this out and accept it as a solution. Thank you so much.