lmailchimp-api
Simple package for MailChimp's List and member management., (*1)
Package Functions Summary:
- Create, update and remove a list
- Add members to a list
- Update members within a list
- Remove member from a list
Developer Note
I am going to fine tune this a bit more first before I upload it to packagist.org., (*2)
To use this package make sure you have obtained API key from your MailChimp account and set it into the .env file from laravel., (*3)
LMAILCHIMP_API_KEY=[your-api-key]
Assumption
These APIs are build and tested internally. If you are intended to use and open for external sources, please make sure to handle the CORS on the main Laravel app. E.g. create a controller to use the MailChimpApiService class directly., (*4)
However there are some additional package you might want to install to handle the CORS e.g. barryvdh/laravel-cors, (*5)
API Manual
Below are the information on how you can use for the API methods. I have included some request samples for each API., (*6)
Get existing lists from your MailChimp Account
API Endpoint:, (*7)
/api/lmailchimp/lists/
Method: GET, (*8)
Example Json Response:, (*9)
{
"success": true,
"lists": [
{
"id": "844a96be1c",
"web_id": 416057,
"name": "Developer Test (Edit)",
"contact": {
"company": "testing company ltd",
"address1": "46 Budd Street",
"address2": "",
"city": "Collingwood",
"state": "VIC",
"zip": "3066",
"country": "US",
"phone": "0389237658"
},
"permission_reminder": "You received this email because we are doing testing",
:
},
{
"id": "86c07e8fb9",
"web_id": 177061,
"name": "Developers",
"contact": {
"company": "Integrated Node",
"address1": "PO Box 291",
"address2": "",
"city": "CANNINGTON",
"state": "WA",
"zip": "6987",
"country": "AU",
"phone": ""
},
"permission_reminder": "You are receiving this email because you are one of the developers list in our developer list. If you found this information is incorrect, please kindly report this to our administrator.",
:
}
],
"total_items": 2
}
Create a new List in MailChimp
API Endpoint:, (*10)
/api/lmailchimp/lists
Method: POST, (*11)
Example for Request, (*12)
{
"name": "Developer Test",
"contact.company": "testing company ltd",
"contact.address1": "46 Test Street",
"contact.address2": "",
"contact.city": "Collingwood",
"contact.state": "VIC",
"contact.zip": "3066",
"contact.country": "Australia",
"contact.phone": "0389237658",
"permission_reminder": "You received this email because we are doing testing",
"use_archive_bar": false,
"campaign_defaults.from_name": "Fei Kwok",
"campaign_defaults.from_email": "softfishtest@gmail.com",
"campaign_defaults.subject": "Test List Laravel Package Subject",
"campaign_defaults.language": "English",
"notify_on_subscribe": "",
"notify_on_unsubscribe": "",
"email_type_option": false,
"visibility": "prv"
}
Response JSON, (*13)
{
"success": true,
"message": "New list has been created.",
"new_list": {
"id": "c6934bea55",
"web_id": 416165,
:
}
}
Update existing list info.
API Endpoint:, (*14)
/api/lmailchimp/lists/[list id]
Method: PATCH/PUT, (*15)
The request JSON structure and attributes are the same as list creation. The response are the same, just the message is different., (*16)
Delete an existing list info.
API Endpoint:, (*17)
/api/lmailchimp/lists/[list_id]
Method: DELETE, (*18)
Add new member to the list
API Endpoint:, (*19)
/api/lmailchimp/lists/[list id]/members
Method: POST, (*20)
Example of JSON Request, (*21)
{
"email_address": "test@email.com",
"email_type": "html",
"status": "subscribed",
"language": "English",
"vip": true,
"ip_signup": "122.321.12.1",
"timestamp_signup": "2018-03-21 22:21:21"
}
Update an existing member info
API Endpoint:, (*22)
/api/lmailchimp/lists/[list id]/members
Method: PATCH/PUT, (*23)
Request are the same as the creation for new member above., (*24)
Remove member from a list
API Endpoint:, (*25)
/api/lmailchimp/lists/[list id]/members
Method: DELETE, (*26)
All you need for the delete member function is to include the email in the request., (*27)
Example Request JSON, (*28)
{
"email": "test@email.com"
}