Webhooks

Webhooks allow you to subscribe to real-time notifications about various events that occur in MailerLite. For example, when a new subscriber is added to your account, HTTP POST callback is sent to your provided URL with a payload containing the new subscriber. It allows you to get the most recent updates without constantly polling the API. You can see your existing webhooks, create new, update and delete them.

Available events

EventDescription
subscriber.createdFires when a new subscriber is added to an account.
subscriber.updatedFires when any of the subscriber's custom fields are updated or when they confirm their subscription.
subscriber.unsubscribedFires when a subscriber becomes unsubscribed.
subscriber.added_to_groupFires when a subscriber is added to a group.
subscriber.removed_from_groupFires when a subscriber is removed from a group.
subscriber.added_through_formFires when a subscriber is added though a form.
subscriber.bouncedFires when an email address bounces.
subscriber.automation_triggeredFires when subscriber starts automation.
subscriber.automation_completedFires when subscriber finishes automation.
subscriber.spam_reportedFires when subscriber marks a campaign as a spam.
campaign.sentFires when campaign is sent.

Delivery attempts and retries

A webhook event is considered delivered when your webserver responds with 2XX status code. Make sure you don't return 4XX or 5XX status codes as part of your business logic, as you will keep getting duplicate webhook events.

Your webserver should respond in less than 3 seconds, otherwise webhook is considered failed. For this reason you should not do any heavy processing in the same request cycle and offload it to a different process.

Upon failure (timeout or non-2XX status code) webhook events are retried three more times with 10, 100, and finally 1000 seconds delay.

Security

Webhook requests include Signature header, its value is HMAC (sha256) which is generated from payload JSON using webhook's secret. You can check its validity in order to be guaranteed that a request is sent from our side.

An example of a function which produces a signature in PHP:

public function generateSignature(string $jsonPayload, string $secret): string
{
    return hash_hmac('sha256', $jsonPayload, $secret);
}
1
2
3
4

List all webhooks

GET https://connect.mailerlite.com/api/webhooks
1

Response

Response code: 200 OK
1
{
  "data": [
    {
      "id": "68079566047937883",
      "name": "Test 2",
      "url": "http://google.com",
      "events": [
        "subscriber.created"
      ],
      "enabled": true,
      "secret": "ybmcD7PQ9R",
      "created_at": "2022-10-04 23:22:13",
      "updated_at": "2022-10-04 23:54:04"
    },
    {
      "id": "68078863100413274",
      "name": "Test",
      "url": "http://google.com",
      "events": [
        "subscriber.created"
      ],
      "enabled": true,
      "secret": "9JVEvb07Yq",
      "created_at": "2022-10-04 23:11:03",
      "updated_at": "2022-10-04 23:11:03"
    },
    {
      "id": "68078820398204249",
      "name": "Test",
      "url": "http://google.com",
      "events": [
        "subscriber.created"
      ],
      "enabled": true,
      "secret": "yXIrayUCWJ",
      "created_at": "2022-10-04 23:10:22",
      "updated_at": "2022-10-04 23:10:22"
    },
    {
      "id": "68074372003267924",
      "name": "Eveniet vero minus.",
      "url": "http://www.marvin.com/omnis-accusamus-est-rem-delectus-quaerat.html",
      "events": [
        "subscriber.bounced"
      ],
      "enabled": true,
      "secret": "Kn556GohSH",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372003267926",
      "name": "Et voluptatibus et est voluptatibus.",
      "url": "http://harber.net/ipsa-molestias-voluptatem-fugiat-quis-tempora-ullam.html",
      "events": [
        "subscriber.automation_completed"
      ],
      "enabled": true,
      "secret": "WXS0dF3FHc",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372005365080",
      "name": "Perferendis dolorem aut nulla.",
      "url": "http://www.brekke.com/",
      "events": [
        "subscriber.added_to_group"
      ],
      "enabled": true,
      "secret": "Ko17Uw3hiB",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372004316503",
      "name": "Tenetur delectus eum fugiat.",
      "url": "http://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam",
      "events": [
        "subscriber.bounced"
      ],
      "enabled": true,
      "secret": "4jQ3Y4UlLI",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372001170769",
      "name": "Tempore voluptatem et voluptas.",
      "url": "http://www.pfeffer.net/quod-voluptatibus-explicabo-nihil-ipsum-accusamus-error",
      "events": [
        "subscriber.removed_from_group"
      ],
      "enabled": true,
      "secret": "hvHGn2D4yu",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372001170770",
      "name": "Vel inventore rem.",
      "url": "http://kautzer.com/consequatur-neque-eaque-ad-et-rem-labore-ut.html",
      "events": [
        "subscriber.created"
      ],
      "enabled": true,
      "secret": "xbzp318Djs",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372003267925",
      "name": "Voluptas animi consequatur.",
      "url": "http://www.oconner.org/laudantium-ipsa-ad-distinctio-eos-quasi-dicta.html",
      "events": [
        "campaign.sent"
      ],
      "enabled": true,
      "secret": "3b1EMAhuoT",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074371998025039",
      "name": "Expedita esse est fugit.",
      "url": "https://www.deckow.com/aut-quae-voluptate-ab-qui-qui",
      "events": [
        "subscriber.removed_from_group"
      ],
      "enabled": true,
      "secret": "QbVgXU0L93",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372000122192",
      "name": "Autem culpa perferendis quaerat.",
      "url": "http://homenick.biz/tempora-asperiores-qui-alias-voluptas-eos-necessitatibus-et",
      "events": [
        "subscriber.automation_completed"
      ],
      "enabled": true,
      "secret": "N3cZ5WO2ep",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    },
    {
      "id": "68074372002219347",
      "name": "Officia quia aut.",
      "url": "https://www.cartwright.org/mollitia-corporis-ipsam-reiciendis-dolor-error-amet-velit",
      "events": [
        "subscriber.updated"
      ],
      "enabled": true,
      "secret": "xRyma5WnWP",
      "created_at": "2022-10-04 21:59:40",
      "updated_at": "2022-10-04 21:59:40"
    }
  ],
  "links": {
    "first": "http://localhost:8080/api/webhooks?page=1",
    "last": "http://localhost:8080/api/webhooks?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "links": [
      {
        "url": null,
        "label": "« Previous",
        "active": false
      },
      {
        "url": "http://localhost:8080/api/webhooks?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "active": false
      }
    ],
    "path": "http://localhost:8080/api/webhooks",
    "per_page": 50,
    "to": 13,
    "total": 13
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

Get a webhook

GET https://connect.mailerlite.com/api/webhooks/{webhook_id}
1

Response

Response code: 200 OK
1
{
  "data": {
    "id": "68074372004316503",
    "name": "Tenetur delectus eum fugiat.",
    "url": "http://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam",
    "events": [
      "subscriber.bounced"
    ],
    "enabled": true,
    "secret": "4jQ3Y4UlLI",
    "created_at": "2022-10-04 21:59:40",
    "updated_at": "2022-10-04 21:59:40"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Error

When providing an invalid webhook id

Response code: 404 Not Found
1

Create a webhook

POST https://connect.mailerlite.com/api/webhooks
1

Request body

ParameterTypeRequiredLimitations
namestringno
eventsarrayyesMust be one of the events described in following table
urlstringyes
enabledbooleanno

Response

Response code: 200 OK
1
{
  "data": {
    "id": "68074372004316503",
    "name": "Tenetur delectus eum fugiat.",
    "url": "http://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam",
    "events": [
      "subscriber.bounced"
    ],
    "enabled": true,
    "secret": "4jQ3Y4UlLI",
    "created_at": "2022-10-04 21:59:40",
    "updated_at": "2022-10-04 21:59:40"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Update a webhook

PUT https://connect.mailerlite.com/api/webhooks/{webhook_id}
1

Request body

ParameterTypeRequiredLimitations
namestringno
eventsarrayno
urlstringno
enabledbooleanno

Response

Response code: 200 OK
1
{
  "data": {
    "id": "68074372004316503",
    "name": "Tenetur delectus eum fugiat.",
    "url": "http://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam",
    "events": [
      "subscriber.bounced"
    ],
    "enabled": true,
    "secret": "4jQ3Y4UlLI",
    "created_at": "2022-10-04 21:59:40",
    "updated_at": "2022-10-04 21:59:40"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Delete a webhook

DELETE https://connect.mailerlite.com/api/webhooks/{webhook_id}
1

Response

Response code: 204 No Content
1
Last Updated: