POST
/
marketing
/
v3
/
emails
/
ab-test
/
create-variation
Create an A/B test variation
curl --request POST \
  --url https://api.hubapi.com/marketing/v3/emails/ab-test/create-variation \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "contentId": "7",
  "variantName": "AB Test - Number 7"
}'
{
  "activeDomain": "test.hs-sites.com",
  "archived": false,
  "campaign": "1b7f51a6-33c1-44d6-ba28-fe81f655dced",
  "content": {
    "flexAreas": {
      "main": {
        "boxed": false,
        "isSingleColumnFullWidth": false,
        "sections": [
          {
            "columns": [
              {
                "id": "column_1606761806181_0",
                "widgets": [
                  "module_160676180617911"
                ],
                "width": 12
              }
            ],
            "id": "section_1606761806181",
            "style": {
              "backgroundColor": "",
              "backgroundType": "CONTENT"
            }
          },
          {
            "columns": [
              {
                "id": "column-0-1",
                "widgets": [
                  "module-0-1-1"
                ],
                "width": 12
              }
            ],
            "id": "section-0",
            "style": {
              "backgroundType": "CONTENT",
              "paddingBottom": "40px",
              "paddingTop": "40px"
            }
          },
          {
            "columns": [
              {
                "id": "column-1-1",
                "widgets": [
                  "module-1-1-1"
                ],
                "width": 12
              }
            ],
            "id": "section-1",
            "style": {
              "backgroundColor": "",
              "backgroundType": "CONTENT",
              "paddingBottom": "0px",
              "paddingTop": "0px"
            }
          }
        ]
      }
    },
    "plainTextVersion": "This is custom! View in browser ({{view_as_page_url}})\n\nHello {{ contact.firstname }},\n\nPlain text emails have minimal formatting so your reader can really focus on what you have to say. Introduce yourself and explain why you’re reaching out.\n\nEvery email should try to lead the reader to some kind of action. Use this space to describe why the reader should want to click on the link below. Put the link on its own line to really draw their eye to it.\n\nLink text\n\nNow it’s time to wrap up your email. Before your signature, thank the recipient for reading. You can also invite them to send this email to any of their colleagues who might be interested.\n\nAll the best,\n\nYour full name\n\nYour job title\n\nOther contact information\n\n{{site_settings.company_name}}, {{site_settings.company_street_address_1}}, {{site_settings.company_street_address_2}}, {{site_settings.company_city}}, {{site_settings.company_state}} {{site_settings.company_zip}}, {{site_settings.company_country}}, {{site_settings.company_phone}}\n\nUnsubscribe ({{unsubscribe_link_all}})\n\nManage preferences ({{unsubscribe_link}})",
    "styleSettings": {},
    "templatePath": "@hubspot/email/dnd/plain_text.html",
    "widgets": {
      "module-0-1-1": {
        "body": {
          "css_class": "dnd-module",
          "html": "<p style=\"margin-bottom:10px;\">Hello {{ contact.firstname }},<br><br>Plain text emails have minimal formatting so your reader can really focus on what you have to say. Introduce yourself and explain why you’re reaching out.</p><p style=\"margin-bottom:10px;\">Every email should try to lead the reader to some kind of action. Use this space to describe why the reader should want to click on the link below. Put the link on its own line to really draw their eye to it.</p><p style=\"margin-bottom:10px;\"><a target=\"_blank\" rel=\"noopener\">Link text</a></p><p style=\"margin-bottom:10px;\">Now it’s time to wrap up your email. Before your signature, thank the recipient for reading. You can also invite them to send this email to any of their colleagues who might be interested.</p><p style=\"margin-bottom:10px;\">All the best,<br>Your full name<br>Your job title<br>Other contact information</p>",
          "i18nKey": "richText.plainText",
          "path": "@hubspot/rich_text",
          "schema_version": 2
        },
        "child_css": {},
        "css": {},
        "id": "module-0-1-1",
        "module_id": 1155639,
        "name": "module-0-1-1",
        "order": 2,
        "styles": {},
        "type": "module"
      },
      "module-1-1-1": {
        "body": {
          "align": "center",
          "css_class": "dnd-module",
          "font": {
            "color": "#23496d",
            "font": "Arial, sans-serif",
            "size": {
              "units": "px",
              "value": 12
            }
          },
          "link_font": {
            "color": "#00a4bd",
            "font": "Helvetica,Arial,sans-serif",
            "size": {
              "units": "px",
              "value": 12
            },
            "styles": {
              "bold": false,
              "italic": false,
              "underline": true
            }
          },
          "path": "@hubspot/email_footer",
          "schema_version": 2,
          "unsubscribe_link_type": "both"
        },
        "child_css": {},
        "css": {},
        "id": "module-1-1-1",
        "module_id": 2869621,
        "name": "module-1-1-1",
        "order": 3,
        "styles": {},
        "type": "module"
      },
      "module_160676180617911": {
        "body": {
          "font": {
            "color": "#00a4bd",
            "font": "Arial, sans-serif",
            "size": {
              "units": "px",
              "value": 12
            },
            "styles": {
              "bold": false,
              "italic": false,
              "underline": true
            }
          },
          "hs_enable_module_padding": false,
          "hs_wrapper_css": {}
        },
        "child_css": {},
        "css": {},
        "id": "module_160676180617911",
        "module_id": 2794854,
        "name": "module_160676180617911",
        "styles": {},
        "type": "module"
      },
      "preview_text": {
        "body": {
          "value": ""
        },
        "child_css": {},
        "css": {},
        "id": "preview_text",
        "label": "Preview Text <span class=help-text>This will be used as the preview text that displays in some email clients</span>",
        "name": "preview_text",
        "order": 0,
        "styles": {},
        "type": "text"
      }
    }
  },
  "createdAt": "2020-11-30T18:43:17.136Z",
  "createdById": 3739732,
  "from": {
    "fromName": "Bruce Wayne",
    "replyTo": "test@hubspot.com"
  },
  "id": "38175169118",
  "isPublished": false,
  "isTransactional": false,
  "language": "en",
  "name": "My subject",
  "publishDate": "2020-11-30T18:44:20.387Z",
  "sendOnPublish": true,
  "state": "DRAFT",
  "subcategory": "batch",
  "subject": "My subject",
  "subscriptionDetails": {
    "officeLocationId": "5449392956"
  },
  "to": {
    "contactIds": {},
    "contactIlsLists": {
      "exclude": [
        1
      ],
      "include": [
        5
      ]
    },
    "suppressGraymail": true
  },
  "type": "BATCH_EMAIL",
  "updatedAt": "2020-11-30T18:44:20.384Z",
  "updatedById": 3739732,
  "webversion": {
    "expiresAt": "2020-11-30T18:44:20.387Z",
    "metaDescription": "",
    "redirectToPageId": 0,
    "redirectToUrl": "http://www.example.org"
  }
}
Supported products
Requires one of the following products or higher.
Marketing HubMarketing HubFree
Sales HubSales HubFree
Service HubService HubFree
Content HubContent HubFree

Required Scopes

This API requires one of the following scopes:
  • content

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Body

application/json

Request body object for creating A/B tests.

Response

201
application/json

successful operation

A marketing email