Automations through the API
What you can do
Section titled “What you can do”- Create, change and delete a company’s automation rules.
- Turn them on, turn them off and apply them to older records.
- Read what each rule did and why it skipped.
This is the admin API (/api/v1), with the company’s secret key. The Automations module must be on.
Key rights
Section titled “Key rights”A rule saved with a key runs with that key’s rights. If the key is revoked or expires, the rule stops.
| What the rule does | Scope needed |
|---|---|
| any save | automations:write |
| the trigger | read on its module, for example invoices:read |
task step |
tasks:write |
client_message step |
parties:write |
chat step |
chat:read |
bonus_points step |
loyalty:write |
A rule
Section titled “A rule”POST /api/v1/automations
{ "name": "7 days past due", "trigger_key": "invoice.overdue", "trigger_days": 7, "conditions": { "match": "all", "rules": [{ "field": "remaining", "op": "gte", "value": "100" }] }, "steps": [ { "type": "task", "boardId": "<board uuid>", "title": "Call {client} about invoice {number}", "dueInDays": 2 } ], "dry_run": true, "daily_limit": 50}Field names inside steps are camelCase (boardId, userIds, dueInDays).
A rule is created turned off. Turn it on with POST /api/v1/automations/{id}/activate and off with POST /api/v1/automations/{id}/deactivate. Only events and dates from then on are picked up.
With dry_run: true the rule only records what it would do. If you leave the field out, a new rule that writes to clients starts in dry run.
Triggers
Section titled “Triggers”trigger_key |
When | trigger_days |
Conditions | Text variables |
|---|---|---|---|---|
client.created |
new client | - | kind, has_email, has_phone |
- |
appointment.cancelled |
appointment cancelled | - | hours_before |
{date}, {time} |
invoice.issued |
invoice issued | - | has_due_date |
{number}, {due_date} |
invoice.overdue |
invoice past due | days after the due date | remaining |
{number}, {due_date}, {remaining} |
quote.unanswered |
quote with no answer | days after sending | - | {number}, {title} |
contract.expiring |
contract about to expire | days before | - | {number}, {title}, {end_date} |
client.inactive |
client who stopped coming | days since last visit | - | {last_visit} |
subscription.payment_failed |
subscription overdue | - | - | {plan} |
subscription.cancelled |
subscription cancelled | - | - | {plan} |
stock.low |
stock below minimum | repeat every N days | - | {product}, {stock}, {minimum} |
review.received |
review received | - | nps |
{nps} |
course.abandoned |
course abandoned | days without activity | - | {course} |
campaign.clicked |
campaign click | - | - | {campaign} |
contact.unsubscribed |
unsubscribed | - | - | {address} |
event.registered |
event registration | - | - | {event}, {event_date} |
event.payment_abandoned |
payment abandoned | - | - | {event}, {event_date} |
event.attended |
attended | days after the event | - | {event}, {event_date} |
event.absent |
did not come | days after the event | - | {event}, {event_date} |
stamp.reward_earned |
reward earned | - | - | {reward}, {card} |
stamp.reward_expiring |
reward about to expire | days before | - | {reward}, {card}, {expires} |
points.earned |
points earned, once per client | - | balance |
{balance} |
points.idle |
points unused | days without movement | - | {balance}, {last_activity} |
{client} and {company} work everywhere. Campaign triggers need the Messages module, and loyalty triggers also need loyalty automated messages.
Operators in conditions: lt and gte for numbers, yes and no for booleans, is and is_not for kind (person, company).
type |
Fields |
|---|---|
notify |
userIds, title, body |
email |
userIds, subject, body |
task |
boardId, assigneeId, title, description, dueInDays |
wait |
days (1-90), recheck (default true) |
client_message |
channel (email, sms), subject, body, marketing (default true) |
chat |
channelId, body |
webhook |
url (https, public address) |
bonus_points |
points (1-500, once a month per client) |
At most 8 steps, and a wait must be followed by an action. With recheck, the rule continues after the pause only if the situation still holds.
Older records
Section titled “Older records”For date-based triggers, POST /api/v1/automations/{id}/apply_existing also applies the rule to what was there before it was turned on, within the daily limit.
History
Section titled “History”GET /api/v1/automation_runs?filter[automation_id]={id} returns the runs: status (running, waiting, done, failed, skipped), reason, dry_run, resume_at.
Reasons for a skipped run: conditions, daily_limit, no_longer_true, rule_off.
Field reference: automations and automation_runs.