Sending emails

Email format

The BLOCKS JSON document behind the email designer, to write laid-out emails through the API or an AI agent

The email designer saves emails as a JSON document: the BLOCKS format. Use it through the API to write emails with sections, columns, images and buttons. Text stays Markdown, inside text blocks.

WhereHow
Templates, campaigns, flow steps, checkscontentFormat: "BLOCKS" and the document as a string in content
POST /v1/emailsThe document as an object in blocks

MARKDOWN works everywhere too: Markdown content renders like a document with one section holding one text block. Write Markdown for a mostly-text email, blocks for a laid-out one.

The document

A document is a list of sections. A section has 1 to 4 columns, a column holds blocks.

{
  "version": 1,
  "style": { "backgroundColor": "#f4f4f2" },
  "sections": [
    {
      "backgroundColor": "#0f172a",
      "padding": [40, 28, 40, 28],
      "columns": [
        { "width": 100, "blocks": [
          { "type": "heading", "text": "What's new, {{ contact.first_name | default: \"there\" }}", "level": 1, "align": "center" },
          { "type": "button", "label": "Read the changelog", "url": "https://acme.com/changelog" }
        ] }
      ]
    },
    {
      "verticalAlign": "middle",
      "columns": [
        { "width": 50, "blocks": [ { "type": "image", "src": "https://img.kulamail.com/8b1d4e.png", "alt": "Dashboard", "radius": 8 } ] },
        { "width": 50, "blocks": [ { "type": "text", "markdown": "### Faster dashboard\n\nPages load twice as fast." } ] }
      ]
    }
  ]
}
Field
versionRequired, 1
sectionsRequired, the sections in reading order. 60 at most
styleOptional, overrides part of the space theme for this email

The document is 512 KB and 500 blocks at most. Colors are #rrggbb. align is left, center or right. A padding is [top, right, bottom, left], whole numbers from 0 to 80 (px).

Style

Each field is optional and takes the email design of the space when absent.

FieldValue
backgroundColorAround the content
contentBackgroundColorBehind the content
textColor, headingColor, linkColorColors
fontFamily, headingFontFamilyA font id
width520 to 720 (px)
contentStylecard or plain

Sections

FieldValue
columnsRequired. 1 to 4 columns, widths adding up to 100
backgroundColorDefault: the content background
backgroundImageAn https:// URL or a variable, covering the section. backgroundColor shows where the image doesn't
paddingDefault [16, 28, 16, 28] in the card style, [16, 16, 16, 16] in the plain style
radius0 to 32 (px). Default 0
borderColor, borderWidth0 to 4 (px). A color alone gives a 1 px border
gapSpace between columns, 0 to 48 (px). Default 16
verticalAligntop (default), middle or bottom, for the columns
stackOnMobileDefault true: columns stack on phones. false keeps them side by side
hideOnmobile or desktop. Outlook on Windows shows sections hidden on desktop

Columns

FieldValue
widthRequired. 10 to 100, percent of the section
blocksRequired, may be empty
backgroundColorDefault: none
paddingDefault [0, 0, 0, 0]
radius0 to 32 (px)

Blocks

Fields not marked required are optional. Every block also takes:

FieldValue
paddingDefault: per block, below. Spacing between blocks comes from their padding
backgroundColorBehind the block
hideOnmobile or desktop

On a dark section, column or block background, text, headings and links turn white or dark when the theme colors wouldn't read, unless the block sets its own color.

heading

Default padding [0, 0, 12, 0].

FieldValue
textRequired. Inline Markdown: bold, italic, links, variables
level1 to 3. Default 2
alignDefault left
colorDefault: the heading color of the theme
fontSize16 to 56 (px). Default: the size of the level

text

Default padding [0, 0, 16, 0].

FieldValue
markdownRequired. Headings, paragraphs, lists, quotes, tables, links, and the ::: blocks
alignDefault left
colorDefault: the text color of the theme
fontSize12 to 24 (px)
lineHeight1.2 to 2

image

Default padding [0, 0, 16, 0].

FieldValue
srcRequired. An https:// URL or a variable. Upload with the Images API to host it
altAlternative text, shown when images are blocked. Without it, a check warns
hrefLink on the image: https://, mailto: or a variable
width10 to 100, percent of the column. Default 100
alignDefault center
radius0 to 32 (px). Default 0

button

Default padding [8, 0, 16, 0].

FieldValue
labelRequired
urlRequired. https://, mailto: or a variable
variantfilled (default) or outline
alignDefault center
fullWidthtrue to fill the column
color, textColorDefault: the button colors of the theme
radius0 to 40 (px). Default: the button shape of the theme
sizesmall, medium or large. Default: the theme

divider

Default padding [16, 0, 16, 0].

FieldValue
colorDefault: light grey
thickness1 to 8 (px). Default 1
width10 to 100 (percent). Default 100
lineStylesolid (default), dashed or dotted

spacer

Default padding [0, 0, 0, 0].

FieldValue
heightRequired. 4 to 160 (px)

social

Default padding [8, 0, 16, 0].

FieldValue
linksRequired. Up to 12 { "network", "url" }. url is https://, mailto: or a variable
alignDefault center
iconStylecolor (default), dark or light
iconSize16 to 40 (px). Default 24

Networks: facebook, instagram, x, linkedin, youtube, tiktok, github, discord, mastodon, bluesky, threads, pinterest, reddit, twitch, whatsapp, telegram, website, email.

A row of text links, for a header or a footer. Default padding [0, 0, 16, 0].

FieldValue
linksRequired. 1 to 8 { "label", "url" }
alignDefault center
colorDefault: the text color of the theme
fontSize12 to 20 (px). Default 14
separatornone (default), dot or pipe

video

Default padding [0, 0, 16, 0].

FieldValue
urlRequired. A YouTube or Vimeo URL
altText of the link under the thumbnail and in the plain-text version

The email shows the video thumbnail, linking to the video.

Variables

{{ ... }} variables work in every text and URL field: text, markdown, label, src, href, url, backgroundImage. Links of buttons, images, menus, social icons and videos are tracked on marketing emails and checked before sending, like links in the text.

Plain-text version

Kula derives it from the blocks, unless you send your own text:

BlockIn the plain text
heading, textTheir text
buttonLabel: url
imageNothing, or alt: href when it has a link
menuLabel: url, one per line
socialNetwork: url, one per line
dividerA line of dashes
videoalt: url

Sections and columns give their blocks in order.

Fonts

arial, helvetica, georgia, verdana, trebuchet, times, and the Google fonts inter, roboto, open-sans, lato, montserrat, poppins, merriweather, lora, playfair-display, source-serif. Apple Mail and iOS show Google fonts; Gmail and Outlook show a system font instead.

Errors

A document that doesn't follow the format answers 400 invalid_blocks. The message gives the path of the problem:

{
  "error": "invalid_blocks",
  "message": "sections[2].columns[1].blocks[0].url: must be an http(s) URL or a variable",
  "status": 400
}

Writing emails

Designer, design and variables

Images API

Host images for your emails