Issues with Marketing Beta API

Hello,

I have problems with the Marketing Beta API. I have used the POST request

/marketing/v3/emails

to create an email. I have added the parameters name, recipient and widgets to the body of the request, but the output does not contain any of my inputs.

This is my input:

{
"name": "test mail wmf",
"widgets": {
 "module-0-0-0": {
 "body": {
 "alignment": "center",
 "css_class": "dnd-module",
 "hs_enable_module_padding": true,
 "img": {
 "alt": "cropped-logo-3",
 "height": 130,
 "src": "https://f.hubspotusercontent-eu1.net/hubfs/27065384/cropped-logo-3.png",
 "width": 160
 },
 "module_id": 1367093,
 "path": "@hubspot/image_email",
 "schema_version": 2
 },
 "child_css": {},
 "css": {},
 "id": "module-0-0-0",
 "label": null,
 "module_id": 1367093,
 "name": "module-0-0-0",
 "order": 1,
 "smart_type": null,
 "styles": {},
 "type": "module"
 },
 "module-1-0-0": {
 "body": {
 "css_class": "dnd-module",
 "hs_enable_module_padding": true,
 "html": "<p style=\"font-size: 22px; line-height: 175%; text-align: center; font-weight: bold;\"><span style=\"color: #ffffff;\">TITLE_________</span></p>\n<p style=\"font-size: 22px; line-height: 175%; text-align: center; font-weight: bold;\"> </p>\n<p style=\"text-align: center;\"><span style=\"color: #ffffff;\">CONTENT_______</span></p>\n<p style=\"text-align: center;\"> </p>",
 "i18nKey": "richText.welcome.primary",
 "module_id": 1155639,
 "path": "@hubspot/rich_text",
 "schema_version": 2
 },
 "child_css": {},
 "css": {},
 "id": "module-1-0-0",
 "label": null,
 "module_id": 1155639,
 "name": "module-1-0-0",
 "order": 4,
 "smart_type": null,
 "styles": {},
 "type": "module"
 },
 "module-2-0-0": {
 "body": {
 "align": "center",
 "css_class": "dnd-module",
 "font": {
 "color": "#23496d",
 "font": "Arial, sans-serif",
 "size": {
 "units": "px",
 "value": 12
 }
 },
 "hs_enable_module_padding": false,
 "link_font": {
 "color": "#00a4bd",
 "font": "Helvetica,Arial,sans-serif",
 "size": {
 "units": "px",
 "value": 12
 },
 "styles": {
 "bold": false,
 "italic": false,
 "underline": true
 }
 },
 "module_id": 2869621,
 "path": "@hubspot/email_footer",
 "schema_version": 2,
 "unsubscribe_link_type": "both"
 },
 "child_css": {},
 "css": {},
 "id": "module-2-0-0",
 "label": null,
 "module_id": 2869621,
 "name": "module-2-0-0",
 "order": 7,
 "smart_type": null,
 "styles": {},
 "type": "module"
 },
 "module_16794882370691": {
 "body": {
 "hs_enable_module_padding": true,
 "hs_wrapper_css": {
 "padding-bottom": "10px",
 "padding-left": "20px",
 "padding-right": "20px",
 "padding-top": "10px"
 },
 "img": {
 "alt": "2B1A1774KG",
 "height": 373,
 "loading": "disabled",
 "src": "https://th.bing.com/th/id/OIP.ZbG8JS-FXculdsz2UgTnEwHaEK?rs=1&pid=ImgDetMain",
 "width": 560
 },
 "module_id": 1367093
 },
 "child_css": {},
 "css": {},
 "id": "module_16794882370691",
 "label": null,
 "module_id": 1367093,
 "name": "module_16794882370691",
 "order": 2,
 "smart_type": null,
 "styles": {},
 "type": "module"
 },
 "module_16794885704682": {
 "body": {
 "background_color": "#00a4bd",
 "corner_radius": 8,
 "destination": "https://cutt.ly/BallinrobeTeeTimes",
 "font": "Arial, sans-serif",
 "font_color": "#ffffff",
 "font_size": 16,
 "font_style": {
 "color": "#ffffff",
 "font": "Arial, sans-serif",
 "size": {
 "units": "px",
 "value": 16
 },
 "styles": {
 "bold": true,
 "font-weight": "bold",
 "italic": false,
 "underline": false
 }
 },
 "hs_enable_module_padding": true,
 "hs_wrapper_css": {
 "padding-bottom": "10px",
 "padding-left": "20px",
 "padding-right": "20px",
 "padding-top": "10px"
 },
 "module_id": 1976948,
 "text": "BOOK NOW"
 },
 "child_css": {},
 "css": {},
 "id": "module_16794885704682",
 "label": null,
 "module_id": 1976948,
 "name": "module_16794885704682",
 "order": 5,
 "smart_type": null,
 "styles": {},
 "type": "module"
 },
 "module_16794885952833": {
 "body": {
 "hs_enable_module_padding": true,
 "hs_wrapper_css": {
 "padding-bottom": "10px",
 "padding-left": "20px",
 "padding-right": "20px",
 "padding-top": "10px"
 },
 "img": {
 "alt": "Crest",
 "height": 130,
 "src": "https://f.hubspotusercontent-eu1.net/hubfs/27065384/Crest.png",
 "width": 160
 },
 "module_id": 1367093
 },
 "child_css": {},
 "css": {},
 "id": "module_16794885952833",
 "label": null,
 "module_id": 1367093,
 "name": "module_16794885952833",
 "order": 6,
 "smart_type": null,
 "styles": {},
 "type": "module"
 },
 "preview_text": {
 "body": {
 "value": "PREVIEW__________"
 },
 "child_css": {},
 "css": {},
 "id": "preview_text",
 "label": "PREVIEW_______________",
 "name": "preview_text",
 "order": 0,
 "smart_type": null,
 "styles": {},
 "type": "text"
 }
 }
 }
}

An this is the output:

[
 {
 "body": {
 "activeDomain": "ballinrobe-golf-club-27065384.hubspotpagebuilder.eu",
 "archived": false,
 "businessUnitId": "0",
 "content": {
 "templatePath": "",
 "widgets": {}
 },
 "createdAt": "2024-05-28T11:15:11.346Z",
 "createdById": "28031473",
 "deletedAt": "1970-01-01T00:00:00Z",
 "from": {
 "fromName": "",
 "replyTo": ""
 },
 "id": "104267550670",
 "isPublished": false,
 "isTransactional": false,
 "language": "en",
 "name": "test mail wmf",
 "publishDate": "1970-01-01T00:00:00Z",
 "state": "DRAFT",
 "subcategory": "batch",
 "subject": "",
 "subscriptionDetails": {
 "officeLocationId": "63536343264",
 "subscriptionId": "173752775"
 },
 "to": {
 "contactIds": {
 "exclude": [],
 "include": []
 },
 "contactLists": {
 "exclude": [],
 "include": []
 },
 "suppressGraymail": true
 },
 "type": "BATCH_EMAIL",
 "updatedAt": "2024-05-28T11:15:11.346Z",
 "updatedById": "28031473"
 },
 "headers": {
 "date": "Tue, 28 May 2024 11:15:11 GMT",
 "content-type": "application/json;charset=utf-8",
 "transfer-encoding": "chunked",
 "connection": "close",
 "location": "https://api.hubapi.com/marketing/v3/emails/104267550670",
 "cf-ray": "88add34b6c3f1b7a-DUB",
 "cf-cache-status": "DYNAMIC",
 "strict-transport-security": "max-age=31536000; includeSubDomains; preload",
 "vary": "origin",
 "access-control-allow-credentials": "false",
 "x-content-type-options": "nosniff",
 "x-envoy-upstream-service-time": "179",
 "x-evy-trace-listener": "listener_https",
 "x-evy-trace-route-configuration": "listener_https/all",
 "x-evy-trace-route-service-name": "envoyset-translator",
 "x-evy-trace-served-by-pod": "fra04/hubapi-td/envoy-proxy-68d6f869c4-lw5dh",
 "x-evy-trace-virtual-host": "all",
 "x-hubspot-correlation-id": "8a593fb0-be8f-48f8-9553-bfbcbb8e7ff2",
 "x-hubspot-ratelimit-interval-milliseconds": "10000",
 "x-hubspot-ratelimit-max": "100",
 "x-hubspot-ratelimit-remaining": "99",
 "x-hubspot-ratelimit-secondly": "10",
 "x-hubspot-ratelimit-secondly-remaining": "9",
 "x-request-id": "8a593fb0-be8f-48f8-9553-bfbcbb8e7ff2",
 "report-to": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=R0LJoxZ2KiaLEuNggr1itTzGKOiOuGKSwsXqltyN4l69MLoPBWvvQjGyAK5%2FyS7VnjDrPcvABrsyTq35vlLnxW0%2Fsy1In0jiinCcx5J%2Fu1q5C2UQ9yBCr9s%2BXrk2EunF\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
 "nel": "{\"success_fraction\":0.01,\"report_to\":\"cf-nel\",\"max_age\":604800}",
 "server": "cloudflare"
 },
 "statusCode": 201
 }
]

Is there something missing in the body of the request?

Thanks in advance.

Hi there,

It looks like you’re facing some issues with the Marketing Beta API. Here are a few points to check that might help resolve your issue:

  1. Check API Documentation:

    • Ensure that you are using the latest version of the API and that the parameters and structure of your request body align with the latest documentation.
  2. Validate JSON Structure:

    • Make sure your JSON structure is correct. Each module should be properly nested within the “widgets” object. Sometimes, an extra comma or missing brace can cause issues.
  3. Required Parameters:

    • Verify that all required parameters are included. For example, check if the “recipient” parameter is required but missing from your request.
  4. Data Types and Values:

    • Ensure that the data types and values for each parameter match what the API expects. For example, confirm that “module_id” and other numerical values are not mistakenly passed as strings.
  5. API Key and Authentication:

    • Double-check your API key and authentication headers. Sometimes, authentication issues can lead to unexpected results.
  6. Error Messages:

    • Look for any specific error messages in the API response. These can provide clues about what might be going wrong.
  7. Testing with Minimal Data:

    • Try sending a minimal valid request to see if it succeeds. Gradually add more data to identify what might be causing the issue.

Here’s a simplified example to test with minimal data:

{
 "name": "test mail wmf",
 "widgets": {
 "module-0-0-0": {
 "body": {
 "alignment": "center",
 "css_class": "dnd-module",
 "img": {
 "alt": "cropped-logo-3",
 "height": 130,
 "src": "https://f.hubspotusercontent-eu1.net/hubfs/27065384/cropped-logo-3.png",
 "width": 160
 },
 "module_id": 1367093,
 "path": "@hubspot/image_email",
 "schema_version": 2
 },
 "id": "module-0-0-0",
 "type": "module"
 }
 }
}

This minimal example can help verify if your API request structure is correct. If this works, you can then build upon it by adding more modules and data.

I hope these tips help you troubleshoot the issue.