Issue
The mailchimp API docs has so much to say about deleting addresses:
If you want to delete an address anyway, along with all its statistics, make a DELETE call to that address’s endpoint.
But there are 2 ways to delete addresses with MailChimp; you can either "delete and remove" or "delete and archive". (more on that in the non-api docs)
I want to delete and remove from the API, but it looks like the API's delete call only does delete and archive.
How can we specify a delete method from the API?
Also, am I right when I say that the API does "delete and archive" by default?
I'm using the mailchimp-api-v3 npm package, a simplified version of my code is below.
let allTheRequest = []
mailchimp.get({ path: '/search-members?query=' + "if_you_match_this_I_delete_you"}, function(err, data) {
data.full_search.members.forEach(function (value) {
allTheRequest.push({
method:"delete",
path: '/lists/' + value.list_id + '/members/' + crypto.createHash('md5').update(value.email_address).digest('hex'),}
)
})
mailchimp.batch(allTheRequest, function (err, results) {
console.log('@results: ', results);
// It all works, we get down here.
})
});
Solution
Turns out that the way to permanently delete an address is to use a POST with the following path:
/lists/{list_id}/members/{subscriber_hash}/actions/delete-permanent
Here is the link to the docs:
https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#%20
Click on "Action", next to "Delete".
Answered By - Félix Paradis Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.