> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hamla.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Start a campaign automatically

> Let a campaign fire the moment someone enters a segment or your app sends an event — with the guardrails that stop it becoming a mass send.

Most campaigns are something you send. These are campaigns that wait: you set them up once, and they reach each person at their own moment — the day before their renewal, the hour they stop being a new signup, the minute they book.

There are two things a campaign can wait for.

## When someone enters a segment

A segment is a rule, so its members change on their own — someone's renewal date comes closer, someone stops buying, someone finally completes their profile. A campaign can start the moment a person *crosses into* the segment.

In the campaign builder: **Triggers → Segment entry**, then pick the segment.

<Note>
  **Turning this on never messages the people already in the segment.** Only people who enter *after* you switch it on are enrolled. The builder shows you this before you launch, along with how many people entered in the last 7 days — so you know the ongoing volume, not a guess.
</Note>

This is what makes date rules useful. A segment of "renewal date is within the next 3 days" refills itself every day as the clock moves, and each person crosses into it exactly once per cycle — so the reminder reaches them once, on time, without anyone scheduling anything.

## When your app sends an event

If your server tells Hamla what happened — see [Hamla Events](/how-to/hamla-events) — any of those events can start a campaign.

In the campaign builder: **Triggers → Your app's events**, then type the event name exactly as you send it. Hamla suggests the names it has already received from you.

```bash theme={null}
curl -X POST https://app.hamla.io/api/sdk/track \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"event":"trial_ending","identity":{"email":"sara@daftar.co"}}'
```

The vocabulary is yours. A clinic triggers on `treatment_completed`, a SaaS on `quota_exceeded`, an academy on `lesson_finished` — none of these are names Hamla has to know in advance.

<Note>
  This listens to events you send **on purpose** — from your server through the track API, or from your website through `hamla.track('event_name')`. Automatic browser activity — page views, scrolls, exit intent — never counts; it is handled by the **behavioral** trigger type instead, so a campaign can never accidentally fire at everyone who loaded a page.
</Note>

## How often one person can be enrolled

Automatic campaigns are the one place where a small mistake could reach thousands of people at once, so there are limits you do not have to configure:

* **Once per campaign, per person.** A person who qualifies again is not enrolled again — unless you turn on **Can enter again later**, which lets them be enrolled once more in a later period. Use it for things that genuinely repeat, like an annual renewal.
* **A cap across every automatic campaign.** Even with several live at once, one person will not be pulled into all of them on the same day. When a campaign is refused for this reason it is skipped, not queued — nobody gets a pile of delayed messages later.
* **Editing a segment's rule sends nothing.** Rules change constantly while you refine them, and thousands of people can cross in and out as you do. Only real-world change — an event arriving, or time passing — can start a campaign.

Unsubscribes, channel consent and your plan's limits apply exactly as they do for a normal send.

## Choosing between them

| You want to reach someone…                  | Use                                             |
| ------------------------------------------- | ----------------------------------------------- |
| the moment they do a specific thing         | Your app's events                               |
| when they become a certain *kind* of person | Segment entry                                   |
| a set number of days before or after a date | Segment entry, with a date rule                 |
| when they stop doing something              | Segment entry — absence is a rule, not an event |

That last row is worth reading twice. "Hasn't bought in 60 days" is not something your app can send, because nothing happens when someone *doesn't* act. It is a segment, and entering it is the moment worth acting on.
