Add every WhatsApp opt-in to your MailerLite subscriber group, look up whether a contact is already subscribed before sending a campaign, and keep both channels in sync without any manual CSV exports.
Before following this guide, read the External API Request step foundation guide. It covers every field in the step interface so this guide can focus on MailerLite-specific values.
MailerLite split into two versions in March 2022. Which version you are on determines both your base URL and your auth header. New MailerLite (account created after 22 March 2022): base URL https://connect.mailerlite.com/api, header Authorization: Bearer YOUR_KEY. Classic MailerLite (before 22 March 2022): base URL https://api.mailerlite.com/api/v2, header X-MailerLite-ApiKey: YOUR_KEY. This guide covers the new version. Classic users: see the reference section below.
Authorization: Bearer YOUR_API_KEY.MailerLite API: developers.mailerlite.com
MailerLite calls lists groups. Group IDs are strings. Fetch them once and store the ID where WhatsApp opt-ins should land.
{{
"data": [
{{
"id": "123456789",
"name": "WhatsApp Opt-Ins",
"active_count": 1204,
"unsubscribed_count": 23
}}
]
}}
Copy: data[0].id = "123456789"Check whether the WhatsApp contact is already subscribed before adding them.
Found (HTTP 200):
{{
"data": {{
"id": "987654321",
"email": "priya@example.com",
"status": "active",
"fields": {{
"name": "Priya Sharma",
"phone": "+919820000001"
}},
"groups": [
{{"id": "123456789", "name": "WhatsApp Opt-Ins"}}
]
}}
}}
Not found: HTTP 404
Map: data.id -> subscriber_id
data.status -> subscriber_status (active/unsubscribed/unconfirmed)
data.groups (check if already in the target group)The POST /subscribers endpoint is an
upsert. Include the group ID in the
groups array and the subscriber is created (or updated)
and added to the group in a single call.
Body:
{{
"email": "{{customer_email}}",
"fields": {{
"name": "{{customer_name}}",
"phone": "{{customer_phone}}"
}},
"groups": ["123456789"],
"status": "active"
}}
Response (HTTP 200 or 201):
{{
"data": {{
"id": "987654321",
"email": "priya@example.com",
"status": "active",
"groups": [{{"id": "123456789", "name": "WhatsApp Opt-Ins"}}]
}}
}}
This is an upsert: creates if new, updates if the email already exists.
HTTP 200 = existing subscriber updated.
HTTP 201 = new subscriber created.Unlike ActiveCampaign (which needs a separate contactLists call) or Klaviyo (which needs a separate list relationship call), MailerLite's POST /subscribers handles both creation and group assignment at once. Include the group ID in the groups array and it is done.
Subscriber status values:
| Status | Meaning |
|---|---|
| active | Subscribed and receiving emails |
| unsubscribed | Opted out; cannot be re-subscribed via API |
| unconfirmed | Pending double opt-in confirmation |
| bounced | Hard bounce; email is invalid |
| junk | Spam complaint |
Only active subscribers receive campaigns. Set status: active for WhatsApp opt-in contacts.
Trigger: Customer messages 'JOIN' on WhatsApp.
Captured: {{customer_email}} = priya@example.com
{{customer_name}} = Priya Sharma
{{customer_phone}} = +919820000001
Step 1 — Check existing (GET /subscribers/email):
GET https://connect.mailerlite.com/api/subscribers/priya@example.com
Authorization: Bearer YOUR_KEY
Response: HTTP 404 (not found)
Conditions:
HTTP 200 -> check data.groups for group membership
if already in group -> 'You are already subscribed!'
if not in group -> add to group (POST /subscribers)
HTTP 404 -> run Step 2
Step 2 — Create and group (POST /subscribers):
POST https://connect.mailerlite.com/api/subscribers
Body: {{email: 'priya@example.com',
fields: {{name: 'Priya Sharma', phone: '+919820000001'}},
groups: ['123456789'],
status: 'active'}}
Response: HTTP 201, data.id = '987654321'
Bot replies:
'You are now subscribed, Priya! You will receive our newsletter
at priya@example.com.'Classic MailerLite uses a different base URL and header. The endpoint structure is similar but the auth and URL both differ.
| Setting | New MailerLite | Classic MailerLite |
|---|---|---|
| Base URL | https://connect.mailerlite.com/api | https://api.mailerlite.com/api/v2 |
| Auth header | Authorization: Bearer YOUR_KEY | X-MailerLite-ApiKey: YOUR_KEY |
| Get groups | GET /groups | GET /groups |
| Add subscriber | POST /subscribers | POST /subscribers |
| Subscriber lookup | GET /subscribers/{email} | GET /subscribers/{email} |
API keys are generated the same way in both versions: account settings → Integrations → API.
| Symptom | Likely cause | Fix |
|---|---|---|
| 401 Unauthorized | Wrong auth header or wrong version | New MailerLite: Authorization: Bearer YOUR_KEY. Classic: X-MailerLite-ApiKey: YOUR_KEY. Also check your base URL matches your version. |
| 404 on subscriber GET | Subscriber not in MailerLite | Expected for new contacts. Proceed to POST /subscribers to add them. |
| Subscriber not in group after POST | Group ID omitted or wrong | Include the group ID in the groups array: ['123456789']. Confirm the ID from GET /groups. |
| Cannot re-subscribe unsubscribed contact | MailerLite blocks re-subscription | An unsubscribed contact cannot be re-added via API. They must re-subscribe themselves via a form or opt-in link. |
| 429 Too Many Requests | Rate limit of 120 per minute exceeded | Check X-RateLimit-Remaining. For a WhatsApp bot doing single lookups, this limit is very generous. |
Mailchimp: data centre prefix, anystring Basic Auth, subscriber upsert.
Read guide →Free trial, no credit card. If you get stuck, we answer live on WhatsApp.