Some of the moments worth an email never happen in a browser: a card is declined, a trial is about to end, an export finishes. A trigger names one of those moments. Each time it happens your product's backend sends Behavly an event for the person, and a Trigger Campaign that starts on that trigger takes them in the moment it arrives.
Make The Trigger
- 1Open Triggers in the main menu and click New trigger. You can also make one while you build: a new Trigger Campaign offers New trigger when it opens, and so does its Who enters step.
- 2Give it a Name, like Payment failed. The Key follows it (
payment_failed): it is what your code sends, and it can't change once the trigger exists. - 3Under Payload, list the details each event carries, each with a type (text, number, yes/no, date or list) and whether it is required. Or paste an example under Example JSON and choose Apply to fields.
- 4Click Create trigger. Behavly shows the request that sends it, in cURL, JavaScript, Python, Java, C#, Go, PHP or Ruby.
- 5On the trigger's page, Create an Agent opens a new Trigger Campaign that already starts on it.
The person is always email. It is not a payload field, and an event without it is refused.
Send It From Your Server
Create an API key with Send events only access in Settings → API. That key can send events and nothing else, so if it ever leaks it cannot read your contacts or change anything. Keep it on your server and send each event to send_event:
curl -X POST 'https://behavly.io/api/v1/send_event' \
-H "Authorization: Bearer $BEHAVLY_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"event":"payment_failed","email":"ana@example.com","properties":{"plan":"Pro","amount":49}}'- event
- The event's key. Required.
- The person it is about. Required.
- properties
- The details, as JSON. At most 50 keys and 8 KB. A described event's required fields must be there, with the right types.
- occurred_at
- When it happened. Optional; defaults to now, and can be up to 30 days ago.
- idempotency_key
- Your own id for the event. Send it when you retry: the same key twice is one event, counted once.
The answer names each campaign the event started, and why any did not: the person is already on the path (the repeat is noted there), already went through it, sent the same event moments before, already went through it 3 times in 90 days, unsubscribed or bounced, or the campaign is paused. To send many at once, send_events takes up to 100 in one request.
Behavly refuses an event sent from a browser with a key, because a key in a web page can be copied by anyone. On your website, use the snippet's behavly.track("payment_failed", { plan: "Pro" }) instead. It starts the same campaigns for a visitor your site has identified.
Try It Without Code
Every trigger's page has Send a test event. It sends the event now for the address you enter, with example details, exactly as your server would: an active Trigger Campaign that starts on it takes that person in and its emails are real. Test events are not counted against your plan; a workspace can send 30 an hour.
What Happens When One Arrives
- Every active Trigger Campaign that starts on the trigger takes the person in at once. Events from before the campaign was active don't count.
- The usual rules still apply: your Agent guardrails, approval before sending, unsubscribes and bounces. A Trigger Campaign sends Right away by default, so an event that arrives at night gets its email at night; choose Only in a window under Sending to hold it for your hours instead.
- People already on any path who wait for, branch on or aim for that trigger (a wait, a branch, the goal or skip if done) move on right away.
Each trigger's page lists the last 25 events received, with the details each carried and what it did. That is the place to look when a trigger seems to do nothing.
Put The Event's Details In Emails
Each payload field can go into the emails a Trigger Campaign sends: {{event.plan}} for a field named plan. After a |, write what it says when there is no value: {{event.plan|your plan}} reads your plan then. Without one, the tag is taken out and the sentence around it mended.
- 1In the template editor, type
{{in the subject or the email, or click the { } button (Insert merge tag). - 2Under Trigger fields, after the other tags, each described trigger lists its fields with their type. The trigger that starts this email's campaign comes first. A trigger you make or change shows the next time the list opens. A field several triggers share, like
plan, is the same tag under each of them. - 3Pick a field. If empty already holds a fallback for it, like
your plan: change it before you pick, or clear it for none. It works in the subject, plain-text emails and designed ones.
- A field is filled from the event that started the person's path. Doing the trigger again while on the path doesn't change it.
- Only a Trigger Campaign has an event. On a Pattern Campaign path, in a test email from the template editor, and when the event didn't carry the field or sent it empty, the fallback is used.
- Text and numbers go in as sent, numbers with thousands separators (
1,250). true and false readyesandno. A list or a nested object never goes in: its tag shows the fallback. - Values are escaped, so a value can't change the email around it: it shows as text, stays on one line, and is encoded inside a link.
To see the email with a trigger's details, click the person icon in the editor's top bar (Preview as a contact) and pick someone. The tags show a sample event of the trigger that starts the template's campaign; under Trigger you can pick another, or No trigger to read the fallbacks a Pattern Campaign path sends.
When The Same Person Does It Again
A payment can fail twice; a signup happens once. If it happens again, on the trigger step, says what a repeat means:
- Once per person
- The default. They go through the path one time, and later events start nothing. For things that happen once, like signing up or starting a trial.
- A new case each time
- For problems that can come back, like a failed payment. A repeat while the problem is open is noted on their path and never starts it over. Reaching the goal (set it to what fixes it, like
payment_succeeded) takes them off the path, and the next one starts a new path at once. Left unfixed, a new path starts 30 days after the last one began. - Again after a break
- For interest that comes back, like viewing pricing. Repeats while they are on the path are noted; 7, 30 or 90 days after leaving (30 by default), they can go through again.
- Every time
- For things that come on a schedule, like a monthly report or a receipt. A repeat while they are on the path is noted; once they have left it, each one starts a new path at once.
For every choice, the same event within 10 minutes counts once, and an unsubscribe, bounce or spam complaint ends it for good. Except with Every time, nobody goes through a path more than 3 times in 90 days. A reply ends only the current path: a later case can still start one. Each repeat shows in the person's timeline as Did the trigger again.
Triggers You Didn't Make
An event with a key Behavly has not seen is still accepted. Its trigger appears in Triggers as not described yet, with fields read from the first event, so you can check them and save.
Limits
Trigger Campaigns work on every plan, Free included, and there is no plan limit on how many are active.
Events from your server count toward your plan's product events each month: 1,000 on Free, 25,000 on Starter, 250,000 on Growth and 1,000,000 on Scale. Events from your website snippet don't count. When the month's allowance is spent, the API answers 402 with a link to upgrade. Each key can make 120 requests a minute.



