# Send a newsletter

> Part of the Cowliss docs. Markdown for every page: append `index.md` to its URL. Site map: /llms.txt

A newsletter in Cowliss is a **list** and the **broadcasts** you send to it. A list belongs to one app: its subscribers are that app's people who said yes to it, and a broadcast is one email to all of them. Under the hood a list is a `marketing.<name>` [purpose](/emails/#purposes), so the same yes also lets your automations send marketing email under it.

Every step on this page works from the dashboard with no code, the [welcome email](#welcome-them) included. The signup form is a block of HTML you paste into your site, and the `cow` commands beside a step do the same from a terminal, for a repo or a coding agent. Nothing here needs a server of your own: see [Without a backend](#without-a-backend).

Running a newsletter for each of your own customers, such as one per artist or per shop? That is [a newsletter per customer of yours](/guides/subscriptions/).

## Before the first send

Once per app:

- A [verified sending domain](/emails/delivery/) for the address the newsletter comes from.
- A **default sender** and a **postal address**, on the app's [Brand](/tracking/apps/#brand) tab. The sender is where the signup confirm email and every broadcast come from; until it is set, the signup form takes no signups. The postal address goes in every broadcast's footer, and a broadcast without one is not sent.

```sh
cow apps look set <appId> --from news@mail.example.com --postal-address "1 Main St, Springfield"
```

## 1. Create the list

On the app's **Marketing** tab choose **New list**, or from a terminal:

```sh
cow lists create <appId> --name newsletter --label "Newsletter"
```

The name is a camelCase word and makes the key `marketing.newsletter`. The label is what a subscriber reads in the footer and on their preferences page. A repo can declare the same list under `purposes` in [`cow.json`](/guides/repo/#cowjson) instead.

## 2. Add people

Use any mix of the three. The list's subscribers show when and how each person joined.

### The hosted signup form

Every list has a public signup page, its `signupUrl`, on the Marketing tab and in `cow lists list <appId>`. Link to it, or put the form on your own site: the Marketing tab copies it as plain HTML that posts to the same URL, so any page that takes a block of HTML can carry it.

Signing up is double opt-in. The person gets a confirm email from the app's default sender and joins only when they click its link. The page, the email and every step after them are in the app's Brand look and language. The [Subscribe reference](/reference/api/subscribe/) has the fields a form posts and its limits.

### A CSV import

On the Marketing tab, **Import subscribers** takes a CSV with a header row naming an `email` column; `first_name` and `last_name` become the traits `firstName` and `lastName`, and every other column a trait of its own name. You confirm that everyone in the file agreed to receive the list.

An import is quiet: it sends no email and starts no automation. Someone who already left this list, or all marketing, is not added back; the import counts them instead. Running the same file twice changes nothing.

### From your app

When someone ticks your newsletter box, grant the list on the `identify` call your server already makes:

```ts
await cow.identify({
  identifiers: { userId: user.id },
  traits: { email: user.email },
  consent: { "marketing.newsletter": form.newsletter },
});
```

`true` adds them and `false` takes them off. Send it only for an answer the person gave: your form is the record of their yes (see [Data protection](/guides/data-protection/#default-3-you-own-the-consent-records)).

## 3. Send a broadcast

Write it on the Marketing tab with **New broadcast**, or as a markdown file from a repo or a coding agent:

```sh
cow broadcasts create --file may.md --list marketing.newsletter --subject "What's new in May"
cow broadcasts test <id>
```

`test` sends it to your own address. In the markdown, `{{firstName|there}}` prints the subscriber's trait or the fallback, and `cow broadcasts create --help` lists the rest. Outside a Cowliss project, name the app with `--app <appId>`.

Sending is a person's job: an admin sends it or schedules it from the dashboard, and the CLI and MCP never send. Who is on the list is decided when sending starts, and it starts only when your credit covers all of them. Each subscriber then passes the same checks as any marketing email (a suppressed address, the frequency cap, their consent at that moment, the spam check), and the broadcast's page counts what happened: delivered, opens, clicks, unsubscribes, bounces and complaints. `cow broadcasts stats <id>` prints the same.

## Welcome them

Open the list in the dashboard and write its **Welcome email**: a subject, a preview line and the body, in the same editor as a broadcast, so it can hand out a discount code or a download link. **Send test to me** shows it in your inbox; then switch it on. Turning it on needs a subject and a body, and a default sender and postal address under **Brand**.

Each person who confirms the hosted signup form gets it once, a moment after the confirm page, under the list's purpose and with its footer, as a broadcast goes. Nobody gets a second one, even after leaving and joining again. People you import or grant the list from your app get none. A welcome skipped because the address is suppressed or the person already left the list stays unsent; one skipped for a passing reason (sending paused or the organization suspended, credit run out, the daily cap, the sending domain, the spam check, a send the provider refused) is tried again if that person confirms the form again. The card counts who it reached and how many it skipped, linked to their reasons in Deliveries.

From the CLI it is `cow lists welcome get`, `set` and `test`. `set` changes only what you pass, so `cow lists welcome set <appId> marketing.newsletter --enabled false` switches it off and keeps the email as written.

### From code

When the welcome needs more than one email, a wait or a condition, write it as an automation: it starts when someone confirms the signup form and sends one template. Put these two files in a [repo](/guides/repo/) and run `cow push`, or ask an agent connected to the [MCP server](/guides/agents/) to create them, then turn the automation on under **Automations** in the dashboard (or `cow enable newsletter-welcome`). Leave the list's own welcome off, or people get both.

```json title="automations/newsletter-welcome.json"
{
  "trigger": { "event": "system.consent_granted" },
  "purpose": "marketing",
  "from": "Acme <news@mail.example.com>",
  "description": "Sends the welcome code to someone who confirmed the newsletter signup form.",
  "steps": [
    {
      "id": "other-grant",
      "type": "branch",
      "if": {
        "or": [
          { "!=": [{ "var": "event.properties.purpose" }, "marketing.newsletter"] },
          { "!=": [{ "var": "event.properties.reason" }, "form"] }
        ]
      },
      "then": [{ "id": "skip", "type": "exit" }]
    },
    { "id": "welcome", "type": "sendEmail", "template": "newsletter-welcome" }
  ]
}
```

```html title="emails/newsletter-welcome.html"
---
subject: Welcome to the Acme newsletter
purpose: marketing.newsletter
preview: Your code for 10% off your first order.
---
<p>Thanks for confirming. You will hear from us once a month.</p>
<p>As promised, 10% off your first order: use the code <strong>WELCOME10</strong> at checkout, or <a href="https://shop.example.com/welcome">open the shop with it applied</a>.</p>
```

Confirming the form writes one [`system.consent_granted`](/reference/system-events/) event for each switch it turned on, `marketing` included, each carrying the `purpose` and the reason `form`. The branch lets only the newsletter's own grant from the form through, so a yes given in your app, on the preferences page or for another list sends nothing. The send adds the footer with the unsubscribe link and your postal address, as it does to a broadcast.

A `marketing` automation reaches each person once, so leaving and signing up again brings no second code. A run that ends at the branch does not count, so someone who joined another list first still gets this welcome when they join this one. To check it before it goes on, give it a [scenario](/automations/testing/) and run `cow test`.

## What leaving does

- **Unsubscribe** in the footer, or the one-click button Gmail and Apple Mail show, takes the person off this list and nothing else.
- **The preferences page** the footer links to switches each list on or off, and offers leaving everything.
- **A spam complaint** turns off all marketing for that person, and **a complaint or a hard bounce** puts the address on the [suppression list](/emails/delivery/#the-suppression-list) for your whole organization.

Each leave is a `system.consent_revoked` [system event](/reference/system-events/) on the person, with the purpose and the reason. To hear about it in your app, forward it to a webhook the way [a newsletter per customer of yours](/guides/subscriptions/#hearing-what-happened) does.

Coming back is the person's choice: they sign up again through the form, or turn the list back on in their preferences. An import never adds them back. Your app can grant the list again with `identify`, and should only on a new yes.

## Without a backend

Everything above runs on Cowliss: the list, the signup form and its confirm email, imports, broadcasts, and the welcome email. Your site only links to the form or carries its HTML.

What does need a server is telling Cowliss about something that happened in your app, such as an order. `identify`, `track` and `emails.send` carry your secret API key, which must never reach a browser, so they run wherever you can keep a secret. Each is one POST:

```sh
curl https://api.cowliss.com/v1/track \
  -H "Authorization: Bearer $COW_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data":{"sourceId":"src_…","identifiers":{"email":"ada@example.com"},"event":"order.placed","properties":{"orderId":"A-2291"},"messageId":"order-A-2291"}}'
```

`messageId` names the event, so a retry is stored once. `identify` is the same shape at `/v1/identify` with `traits` in place of `event`; every field is in the [ingestion reference](/reference/api/ingestion/). Signing in with Clerk? A [Clerk source](/tracking/apps/#connecting-clerk) brings sign-ups in with no code of yours.
