PlugPress

Mailpuff

How AI Agents Write and Edit Emails in Mailpuff

The simple block format AI agents use to write Mailpuff emails: block types, text formatting, merge tags, themes and safe edits.

An AI agent writes a Mailpuff email as a list of simple blocks, such as a heading, a paragraph and a button. Mailpuff turns them into the email editor’s own blocks, so you can open the draft and finish it by hand like any other email. This page is the reference for that format. The agent sends the blocks as JSON to the create-campaign or set-campaign-content tool.

What does a campaign look like in blocks?

Here is a complete create-campaign call. Only subject is required. Without an audience, the campaign goes to everyone subscribed, and the sender comes from Mailpuff’s settings.

{
  "subject": "Our spring sale starts Monday",
  "preheader": "Three days, 20% off everything in the shop.",
  "audience_type": "tag",
  "audience_id": 4,
  "theme": "gazette",
  "blocks": [
    { "type": "heading", "text": "Spring sale, three days only", "level": 1 },
    { "type": "paragraph", "text": "Hi {{first_name}},\nfrom Monday to Wednesday everything is **20% off**." },
    { "type": "list", "items": ["Free shipping over $50", "No code needed", "Ends Wednesday at midnight"] },
    { "type": "button", "text": "Shop the sale", "url": "https://example.com/shop", "align": "center" },
    { "type": "divider" },
    { "type": "paragraph", "text": "Questions? Just reply to this email.", "align": "center" }
  ]
}

The answer has the new campaign’s id, its status (draft), a review_url where the owner reviews and sends it, and an editor_url that opens it in the editor. Nothing is sent.

Instead of blocks, template_id starts the campaign from a saved template. list-templates returns them.

Which block types can an agent use?

There are nine block types.

Type Fields Notes
heading text, level (1, 2 or 3), align
paragraph text, align Use \n for a line break.
list items (array of strings), ordered Set ordered to true for a numbered list.
quote text
button text, url, align, color, text_color Without a color, the button takes the theme’s link color.
image src, alt, href, width, align src must be an http or https address. Width runs from 20 to 600 pixels.
divider None A thin line.
spacer height 4 to 120 pixels, 20 when left out.
columns columns: two or three lists of blocks Side by side, and stacked on a phone. A column can hold any block above, but not more columns.

One body takes up to 200 blocks, and one block up to 5,000 characters.

A two-column block looks like this:

{
  "type": "columns",
  "columns": [
    [ { "type": "heading", "text": "For shops", "level": 3 }, { "type": "paragraph", "text": "Tag buyers and write to them." } ],
    [ { "type": "heading", "text": "For blogs", "level": 3 }, { "type": "paragraph", "text": "Email each new post." } ]
  ]
}

How do I format text inside a block?

Text uses a small part of Markdown.

  • **bold** for bold
  • *italic* for italic
  • [link text](https://example.com) for a link
  • \n for a line break

Merge tags such as {{first_name}} pass through and are filled in for each reader when the email is sent. A link or a button can point at a merge tag, for example "url": "{{manage_subscription_url}}".

Which merge tags work in Mailpuff?

Merge tag Becomes
{{first_name}}, {{last_name}}, {{full_name}} The reader’s name
{{email}} The reader’s email address
{{list_name}} The list’s name
{{field:city}} One of your own subscriber fields. {{field:city|there}} shows “there” to people without a value
{{business_name}}, {{business_address}} Your business name and postal address from Settings
{{site_name}}, {{site_url}} Your site’s name and address
{{unsubscribe_url}} The reader’s unsubscribe link
{{manage_subscription_url}} The reader’s preferences page
{{web_url}} The campaign’s web version, when it is on
{{date}} Today’s date
{{last_post_title}}, {{last_post_url}} Your latest post
{{confirm_url}} The confirm link, in the confirmation email only

The new-post and digest emails have tags of their own, such as {{post_title}} and {{posts}}. get-automatic-email lists the tags each of those emails can use.

Every campaign gets the unsubscribe footer and your postal address on its own, so the agent doesn’t need to add them.

How does an agent change part of an existing email?

To change one part, the agent reads the campaign with get-campaign, edits that one block in the blocks array, and sends the whole array back with set-campaign-content. That call replaces the entire body, including anything the owner changed in the editor since it was read. So the agent should read first, change only what the owner asked for, and write straight after.

Check blocks_exact in the get-campaign answer before you edit:

  • true: the blocks match the email exactly. Edit and send them back.
  • false: the email has parts with no block type, such as social links, a menu, a video, raw HTML, MJML, underline, strikethrough or colored text. The blocks are close but not exact, and writing them back would drop those parts. Change this email in the editor instead.

To change the subject, preview text, sender or audience, use update-campaign. It never touches the body.

How do email themes and styles work?

A theme sets the font, text sizes, colors, backgrounds and corner radius in one go. Mailpuff ships these nine: clean, gazette, charcoal, sage, ember, typewriter, poster, pebble and letter. list-email-themes returns each one with the styles it sets.

Pass theme to create-campaign, or change the look of a campaign with set-campaign-style. That tool takes a theme, single styles on top of it, or both:

{
  "campaign_id": 42,
  "theme": "sage",
  "styles": {
    "font": "georgia",
    "fontSize": 17,
    "linkColor": "#2F6B4F",
    "borderRadius": 12
  }
}
Style Accepted values
font system, helvetica, arial, verdana, trebuchet, georgia, palatino, times, mono, courier
fontSize 12 to 20
h1Size, h2Size, h3Size 12 to 60
lineHeight 1 to 2.2
textColor, headingColor, linkColor #RRGGBB
outerBg, bgColor #RRGGBB for the page and the content area
borderRadius 0 to 24
linkUnderline true or false
footerAlign center or left

set-campaign-style never changes the words. Keep text readable on its background.

Can an agent send HTML or MJML instead?

An agent can pass content_html instead of blocks. Mailpuff removes scripts and unsafe markup. Blocks are the better choice, because the editor opens them as headings, paragraphs, buttons and images the owner can change one by one.

MJML is written in the editor itself: type /mjml to add an MJML block, or choose “Edit as MJML” from the editor menu. The tools don’t take MJML.

What should an agent do after writing the email?

  1. Send a test with send-campaign-test and ask the owner to read it, ideally on a phone.
  2. Run check-send-readiness with the campaign id. It checks preview text, a subject of 60 characters or fewer, Gmail’s 102 KB clipping size and link shorteners, among other things.
  3. Share the review_url so the owner can look before anything goes out.

Sending is covered in What an AI agent can and can’t do.

FAQ

Can an agent add images from my media library?

Yes, with the image’s full URL in src. Add alt text for readers whose email app blocks images.

Why did my button come out in a different color?

A button without color takes the theme’s link color, so it matches the email. Set color and text_color to pick your own.

Does the agent’s draft look the same in the editor?

Yes. Each block becomes the editor’s own block of the same kind, so the owner sees the same email and can change any part of it.