Automation triggers
Create, read, update and delete the triggers that start an automation.
A trigger is what starts an automation. Every automation needs at least one before it can be enabled, and it can have up to three on plans that support multiple triggers.
Create and update calls take the same shape: a type that says what starts the workflow, and a
data object holding the settings for that type. data is optional on create, so you can add an
empty trigger and configure it later. Updates replace the whole data object, so send every field
you want to keep.
Triggers can only be changed while the automation is inactive. A trigger's type cannot be
changed once it exists. Delete it and create a new one instead.
If the automation was deleted, every endpoint on this page returns 410 Gone.
Trigger types
type | Fires when | data fields |
|---|---|---|
subscriber_joins_group | A subscriber is added to a group | group_ids: int[] (required), exclude_group_ids: int[] |
subscriber_joins_segment | A subscriber starts matching a segment | segment_id: int (required, the segment must have a filter) |
clicks_link | A subscriber clicks a link | link: string (required, a valid URL) |
form_completed | A subscriber submits a form or landing page | form_type: string (required), form_id: int (required) |
field_updated | A subscriber's field changes | field_id: int or "email" (required), field_operator: string (required, depends on the field's type), value: mixed (required for operators that compare a value) |
anniversary | A date field comes round again each year | See the date fields below |
exact_date | A date field matches one specific date | See the date fields below |
manual | Only when you add subscribers yourself | None |
purchased_any_product | A subscriber buys anything | ecommerce_shop_id: int (required, an enabled shop) |
purchased_from_category | A subscriber buys from a category | ecommerce_shop_id: int (required), ecommerce_category_id: int (required) |
purchased_specific_product | A subscriber buys a given product | ecommerce_shop_id: int (required), ecommerce_product_id: int (required), variation_ids: int[] (omit for every variant) |
abandoned_cart | A subscriber leaves items in their cart | ecommerce_shop_id: int (required), unit: hours, days, weeks or months (required), value: int (required, min 1) |
abandoned_checkout | A subscriber starts checkout and does not finish | Same as abandoned_cart |
purchase_frequency | A subscriber has not bought again within a period | ecommerce_shop_id: int (required), interval: int (required, min 1), value: int (required, min 1), unit: string (required), order_cap: int (must be at least interval) |
Not every shop supports every e-commerce trigger. Category, abandoned cart and abandoned checkout triggers are unavailable on some connected platforms, and the API rejects a shop that cannot support the trigger you asked for.
Date trigger fields
anniversary and exact_date take the same data fields:
| Field | Type | Required | Notes |
|---|---|---|---|
field_id | int | yes | A date custom field |
group_ids | int[] | yes | Only subscribers in these groups are considered |
exclude_group_ids | int[] | no | Subscribers in these groups are skipped. Cannot overlap group_ids |
send_hour | string | yes | "00" to "23" |
send_minute | string | yes | "00", "15", "30" or "45" |
start_before_time | int | no | Start this long before the date |
start_before_time_unit | string | no | day or month |
start_after_time | int | no | Start this long after the date |
start_after_time_unit | string | no | day or month |
use_timezone | string | no | account, subscriber or custom. Defaults to account |
timezone_id | int | conditional | Required when use_timezone is custom |
start_before_* and start_after_* are mutually exclusive. Send one pair or the other, not both.
For anniversary triggers the offset must stay under 365 days or 12 months.
List automation triggers
Returns every trigger on an automation, with its type and its configuration. An automation can have up to three triggers, depending on your plan.
If you want to get all triggers of an automation use this GET request
GET https://connect.mailerlite.com/api/automations/{automation_id}/triggersResponse
Response code: 200 OK{
"data": [
{
"id": "203114222968636621",
"type": "subscriber_joins_group",
"group_ids": [
"203105145192450069"
],
"groups": [
{
"id": "203105145192450069",
"name": "Test",
"url": "https://connect.mailerlite.com/groups/203105145192450069"
}
],
"exclude_group_ids": [
"203114217220344581"
],
"excluded_groups": [
{
"id": "203114217220344581",
"name": "Newsletter readers",
"url": "https://connect.mailerlite.com/groups/203114217220344581"
}
],
"broken": false,
"complete": true,
"exit_when_no_longer_matches": false
}
]
}Create an automation trigger
Adds a trigger to an automation. type decides what starts the workflow. data holds the settings for that type. The automation must be inactive and below its trigger limit: three triggers on plans that support multiple triggers, one otherwise.
If you want to add a trigger to an automation use this POST request
POST https://connect.mailerlite.com/api/automations/{automation_id}/triggersRequest body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| type | string | yes | What starts the automation. Must be one of the trigger types listed above, for example subscriber_joins_group or abandoned_cart |
| data | object | no | The trigger's configuration. The fields it takes depend on type, see the trigger types table above. Omit it to create an empty trigger and configure it later with the update endpoint |
Request example:
{
"type": "subscriber_joins_group",
"data": {
"group_ids": [
"203105145192450069"
]
}
}Response
Response code: 201 Created{
"data": {
"id": "203114222968636621",
"type": "subscriber_joins_group",
"group_ids": [
"203105145192450069"
],
"groups": [
{
"id": "203105145192450069",
"name": "Test",
"url": "https://connect.mailerlite.com/groups/203105145192450069"
}
],
"exclude_group_ids": [],
"excluded_groups": [],
"broken": false,
"complete": true,
"exit_when_no_longer_matches": false
}
}Get an automation trigger
Returns a single trigger with its type and its configuration.
If you want to get a single trigger use this GET request
GET https://connect.mailerlite.com/api/automations/{automation_id}/triggers/{trigger_id}Response
Response code: 200 OK{
"data": {
"id": "203114222968636621",
"type": "subscriber_joins_group",
"group_ids": [
"203105145192450069"
],
"groups": [
{
"id": "203105145192450069",
"name": "Test",
"url": "https://connect.mailerlite.com/groups/203105145192450069"
}
],
"exclude_group_ids": [
"203114217220344581"
],
"excluded_groups": [
{
"id": "203114217220344581",
"name": "Newsletter readers",
"url": "https://connect.mailerlite.com/groups/203114217220344581"
}
],
"broken": false,
"complete": true,
"exit_when_no_longer_matches": false
}
}Update an automation trigger
Replaces a trigger's configuration. Send the complete data payload for the trigger's type. Fields you leave out are cleared, not kept. The trigger's type cannot be changed here, and the automation must be inactive.
If you want to update a trigger use this PUT request
PUT https://connect.mailerlite.com/api/automations/{automation_id}/triggers/{trigger_id}Request body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| data | object | no | The trigger's configuration. The fields it takes depend on the trigger's type, see the trigger types table above |
Request example:
{
"data": {
"group_ids": [
"203105145192450069"
],
"exclude_group_ids": [
"203114217220344581"
]
}
}Response
Response code: 200 OK{
"data": {
"trigger": {
"id": "203114222968636621",
"type": "subscriber_joins_group",
"group_ids": [
"203105145192450069"
],
"groups": [
{
"id": "203105145192450069",
"name": "Test",
"url": "https://connect.mailerlite.com/groups/203105145192450069"
}
],
"exclude_group_ids": [
"203114217220344581"
],
"excluded_groups": [
{
"id": "203114217220344581",
"name": "Newsletter readers",
"url": "https://connect.mailerlite.com/groups/203114217220344581"
}
],
"broken": false,
"complete": true,
"exit_when_no_longer_matches": false
},
"trigger_data": {
"track_ecommerce": false,
"broken_workflow": false,
"complete_workflow": false,
"show_analytics": true,
"valid": true,
"repeatable": false,
"repeatable_settings": {
"mode": "wait",
"value": 1,
"unit": "day"
}
},
"qualified_subscribers_count": 10
}
}Delete an automation trigger
Removes a trigger from an automation. The automation must be inactive. It cannot be enabled again until it has at least one configured trigger.
If you want to delete a trigger use this DELETE request
DELETE https://connect.mailerlite.com/api/automations/{automation_id}/triggers/{trigger_id}Response
Response code: 204 No Content