---
title: "Emails | Jetstack AI Docs"
description: "Reference for importing and deploying HubSpot marketing emails, including template handling, image extraction, subscription types, and known edge cases."
url: "https://jetstack.ai/docs/implementations/asset-types/emails/"
---

# Emails

Marketing emails are a core HubSpot asset type with significant complexity. An email can reference templates, blogs, lists, subscription types, and template modules, while also containing embedded images and dynamic content. Jetstack AI captures the full email definition and reconstructs it in the destination portal with all references remapped.

## What Jetstack AI Captures

During import, Jetstack AI retrieves the complete email definition:

- **Email metadata** — name, subject line, sender details, email type, state, A/B test configuration
- **Content body** — the full HTML/HubL email body, including inline styles and module references
- **Template configuration** — which template the email is built on, including generated layout references
- **Subscription type** — the email’s subscription category (required for CAN-SPAM/GDPR compliance)
- **List targeting** — which lists receive the email (`contactLists` and `contactIlsLists`)
- **Campaign association** — the campaign group the email belongs to
- **Images** — all images embedded in the email body, extracted using 7 distinct URL patterns

## Email Types

Jetstack AI supports all HubSpot email types:

| Type          | Description                                       |
| ------------- | ------------------------------------------------- |
| **Regular**   | Standard one-time marketing emails                |
| **A/B test**  | Emails with two variants for split testing        |
| **Automated** | Emails sent by workflows (not manually triggered) |
| **RSS**       | Emails triggered by RSS feed updates              |
| **Blog**      | Emails triggered by blog post publications        |

Each type has different state handling and deploy behavior, but the core remapping logic is shared.

## Dependencies

Emails reference several other asset types:

- **Email templates** — the template the email is built on (either a custom template or a generated layout)
- **Blogs** — blog emails reference a specific blog for content sourcing
- **Workflows** — automated emails are associated with the workflow that sends them
- **Lists** — `contactLists` (inclusion) and `contactIlsLists` (exclusion) define the send audience
- **Subscription types** — every email requires a subscription type for compliance
- **Template modules** — custom modules referenced within the email’s HubL content

## Deploy Remapping

### Subscription Type Rebuild

Every email must have a valid subscription type in the destination portal. Jetstack AI remaps the subscription type using the v3 API structure:

```
subscriptionDetails.subscriptionId -> destination subscription type ID
```

If the source email’s subscription type does not have a mapping in the destination, the email will fail to deploy. Ensure subscription types are imported and mapped before deploying emails.

### Template Path Remapping

Emails reference their template by path. Jetstack AI handles two template scenarios:

- **Custom templates** — the template path is remapped to the destination template’s path after it has been deployed
- **Generated layouts** — emails using drag-and-drop editors store their layout at `generated_layouts/{id}.html`. Jetstack AI remaps the `{id}` portion to the destination email’s generated layout ID

### Image Upload

Jetstack AI extracts images from the email body using 7 distinct URL patterns, covering:

- Standard `src="https://..."` image references
- Background image URLs in inline styles
- HubSpot file manager URLs (`f.hubspotusercontent*.net`)
- Protocol-relative image URLs (`//cdn2.hubspot.net/...`)
- Images within HubL module parameters
- Open Graph and social sharing image meta tags
- Featured/preview image URLs

Extracted images are uploaded to the destination portal’s file manager, and all references in the email body are rewritten to point to the new URLs.

### List Targeting Remapping

Emails with list-based targeting include two arrays:

- **`contactLists`** — lists whose members should receive the email
- **`contactIlsLists`** — lists whose members should be excluded

Both arrays are remapped to the corresponding destination list IDs.

### Campaign Group ID Aliasing

Emails belong to campaign groups in HubSpot. When a new email is created in the destination portal, the campaign group ID is not returned immediately in the creation response. Jetstack AI queries the email’s campaign data after creation to retrieve the campaign group ID, which is then stored for use by other assets (like lists) that reference the email by campaign group.

## Edge Cases and Special Handling

### A/B Email State Handling

A/B test emails use special states that differ from standard emails:

- **`DRAFT_AB`** — an A/B email still in draft (both variants editable)
- **`AUTOMATED_DRAFT`** — an automated A/B email in draft state

Jetstack AI preserves the A/B state and deploys both variants. The email is always deployed in a draft state regardless of its source state — it is never auto-published.

### Generated Layout Path Remapping

Emails built with the drag-and-drop editor use a path format of `generated_layouts/{contentId}.html`. The `{contentId}` is the source email’s ID, which will differ in the destination. Jetstack AI updates this path to reference the newly created destination email’s ID after creation. This is a post-creation patch operation.

### Campaign Group ID Timing

After creating an email, the campaign group ID may not be available in the immediate API response. Jetstack AI handles this by:

1. Creating the email
2. Querying the email’s campaign association endpoint
3. Storing the resolved campaign group ID for downstream use

If the campaign group ID cannot be resolved (rare, typically a HubSpot API delay), Jetstack AI retries the resolution up to 3 times with backoff.

## Troubleshooting

### Subscription Type Not Found

If an email fails to deploy with a subscription type error, verify that the subscription type from the source portal has been imported and mapped to a destination subscription type. Subscription types must exist before emails that reference them.

### Images Not Displaying

If images appear broken in the deployed email, check the deploy log for image upload failures. Common causes include:

- Source image URLs that have expired or been deleted
- File size limits in the destination portal’s file manager
- Protocol-relative URLs that could not be resolved

### Template Not Found

If the email’s template was not included in the import, the email cannot be deployed. Ensure all email templates (including generated layouts) are part of the import selection. Check the dependency tree in the import review step to verify template inclusion.
