# Campaigns and broadcast

Broadcasts run on the `broadcast` route against an **active** list, optionally narrowed by a CRM segment.

## Compose

Campaigns → Compose:

- Pick a list and optional **segment**
- Optional template from the library
- **Message kind** sets consent channel and default tracking (`newsletter` on, `termin` / `recall` / `doi` off)
- **Visual editor** — heading, text, button, image, divider, spacer. Drag to reorder. Switch to HTML anytime.
- Merge tags: `{{first_name}}`, `{{email}}`, plus contact attributes
- Conditionals: `{{#if highlight}}…{{/if}}` and `{{#unless field}}…{{/unless}}`

Save draft, schedule, or queue. The worker sends one recipient at a time through the same gate as single send.

## A/B testing

Enable **A/B test subjects**. Variant A uses the main subject; variant B is the alternate.

- Only the sample percentage (default 20%) receives a variant in the first wave
- After **test hours** (default 4) the worker picks a winner by unique opens or clicks
- You can also pick a winner in Analytics
- The remaining audience then receives the winner

`GET /api/practices/{id}/campaigns/{campaignID}` includes `variants` with sent / open / click rates.  
`POST …/ab-winner` with `{ "variant_id" }` promotes immediately.

## Segments

CRM → Segments is a rule builder (`AND` / `OR`). Fields include `status`, `email`, `first_name`, `attr.<key>`, and `relative.created_at` with `within_days` / `older_than_days`. Preview counts, then attach the segment on compose.

## Template library

Campaigns → Templates. **Seed practice presets** adds German Unspam-safe starters: Termin, Recall, DOI, transactional, newsletter, patient feedback. Each preset carries a kind badge and tracking defaults.

`POST /api/practices/{id}/presets/seed` is idempotent per kind.

## Journeys

See [Journeys](/journeys). Linear trigger → delay → template. The built-in seed is **Termin → Recall**.

## Practice kinds

See [Practice mail](/practice-mail). `termin`, `recall`, and `doi` are first-class consent channels.
