Sending emails

Templates

Reusable emails sent by your app, linked to flows or copied into campaigns

A template is a reusable email, written once in Templates:

UseHowStays linked
Sent by your appPOST /v1/emails with its aliasYes: the published version is sent
In a flowAn email step links the templateYes: publishing updates every flow using it
In a campaignStart from when creating the campaignNo: the content is copied

Transactional emails

A transactional email is sent by your app to one person, because of something they just did: a password reset, a sign-in link, a receipt, an invitation. It needs no list and has no unsubscribe link. It travels on its own stream, so it keeps flowing when marketing is paused.

Two ways to send

TemplateRaw content
Content lives inKula: anyone on the team edits it in the dashboardYour code
You sendThe template alias and variablesThe subject and the HTML, Markdown or blocks
Best forMost emailsEmails your app already renders

Create a template

Open Templates › New template. Under Start from, pick a blank email, one of your templates (copied), or a starter template: receipt, password reset, magic link, verification code, and the marketing ones. Starter templates come with their variables and take the design of your space.

The template page has three tabs:

TabHolds
ContentSubject, Preview text and the editor, with Write and Preview
SettingsName (internal), Alias (the key your code sends as template, such as password-reset), sender and variables
Usage and APIThe flows linked to the template and the snippet to send it

Put the main link in a button and sign-in codes in a code (Insert › Code in the text toolbar): the designer.

Variables

Use data.* variables for the values your app sends: {{ data.reset_url }}, {{ data.order.total }}. Declare them in Settings › Variables:

FieldUse
Namereset_url for {{ data.reset_url }}
RequiredThe send is refused without it
ExampleFills the preview and test emails
  • A required variable missing, null or blank: POST /v1/emails answers 400 missing_variables.
  • A data.* used in the content but not declared raises a pre-send check.
  • Variables are versioned with the content: a change goes live on Publish.

If the recipient is also a contact of your space, {{ contact.first_name }} and the contact's attributes work too.

Draft and published versions

A template has a draft and a published version. The API always sends the published version: editing the draft does not change emails in production.

StatusMeaning
DraftNever published: the API refuses to send it
PublishedThe draft and the published version are the same
Unpublished changesYou edited the draft since the last publication

Preview and Send a test use the draft. Click Publish to make the draft live, or Discard draft to go back to the published version.

Publishing also updates every flow linked to the template.

AI assistants can write a template draft but never publish it: they ask a member, who clicks Approve and publish.

Send it from your app

Create an API key in Settings › API keys. A key with sending access is enough, and safer to store in an app. Then call POST /v1/emails:

cURL
curl https://api.kulamail.com/v1/emails \
  -H "Authorization: Bearer $KULA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: reset-8f6c2a1e" \
  -d '{
    "to": "ada@example.com",
    "template": "password-reset",
    "variables": {
      "name": "Ada",
      "reset_url": "https://acme.com/reset?token=abc123"
    }
  }'

The email is queued and leaves within seconds. Usage and API shows the same snippet, in cURL and Node, with your alias and the examples of your variables.

  • Sender: the sender of the template, or the default sender of the space. Override it with from, on a verified domain.
  • Idempotency: send an Idempotency-Key header. If your app retries after a timeout, Kula returns the first email instead of sending a second one.
  • Batches: send up to 100 emails in one call with POST /v1/emails/batch.
  • Tags: attach key/value tags to find the email in webhooks and count by tag.
  • Tracking: off unless you ask, with track. Track opens and clicks.

Every field and error: Emails API.

A tool that can't call an API (Supabase, Ghost, WordPress) sends through the SMTP relay instead.

A separate stream

MarketingTransactional
Priority in the queueNormalFirst
Paused on a reputation alertYesNo
Warm-up of a new domainAppliesSkipped
Contact reviewAppliesSkipped
Unsubscribed contactsSkippedStill receive it
Hard-bounced addressesSkippedSkipped

A hard-bounced address is blocked on both streams: the email comes back with the status SUPPRESSED and is not sent.

Use transactional emails only for messages a person expects after an action. Newsletters and promotions sent through the transactional API skip the unsubscribe rules of inbox providers and break our acceptable use policy.

Use it in a flow

In a flow, an email step either has its own content or links a template. Linked, the step sends the template's published version:

  • publishing a change updates every flow using it;
  • {{ data.x }} reads the trigger event's properties, like {{ event.x }}: a template written for the API works as is in a flow triggered by that event;
  • Detach copies the content into the step and drops the link.

A flow email is a marketing email, even with a template: it carries an unsubscribe link and follows the marketing rules.

RuleWhy
A flow can't be activated while a linked template was never publishedNothing to send yet
A run fails if its trigger event lacks a required variableThe run page names the missing variables
A flow triggered by a list can't link a template with required variablesThere is no event to fill them
A template linked to a flow can't be deletedDetach it or remove the step first

Flows.

Use it in a campaign

In Campaigns › New campaign, pick a template under Start from. Subject, preview text, sender and content are copied into the campaign: later edits to the template don't change it. Campaigns.

Follow what happens

  • Activity lists every email, with its status and events. Filter on the transactional stream.
  • The Usage and API tab shows the flows using the template and its sends over 30 days.
  • Webhooks tell your app when an email is delivered, bounces, is opened or clicked.

Raw content you send (HTML, Markdown or blocks, without a template) is kept 30 days, then deleted.

Track opens and clicks

Transactional emails are not tracked by default. Ask for it email by email:

{
  "to": "ada@example.com",
  "template": "webinar-reminder",
  "variables": { "starts_at": "Thursday, 6 pm" },
  "tags": { "webinar": "w_123", "type": "reminder" },
  "track": { "opens": true, "clicks": true }
}

Over SMTP, add the header X-Kula-Track: opens, clicks. The Track opens and Track clicks settings of the space apply to marketing emails only.

Don't track clicks on an email holding a sign-in, password reset or other single-use link: the link would go through Kula's redirect server and be stored by Kula.

Stats by tag

GET /v1/emails/stats, with a full access key, counts the emails matching your tags, and groupBy splits them. A webinar platform sends an invitation, reminders and a same-day notice for each webinar, tagged webinar and type. The results of webinar w_123, by type:

curl "https://api.kulamail.com/v1/emails/stats?tag=webinar:w_123&groupBy=tag:type" \
  -H "Authorization: Bearer $KULA_API_KEY"

One group per type: invitation, reminder, same-day, each with deliveries, bounces, opens and clicks. Open and click rates are computed over tracked emails only. Get email stats.

Emails API

Fields, batches and errors

Templates API

Manage templates from your code

Webhooks

Delivery, bounce, open and click events