PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 6, 2022

[FIXED] How to "delete and remove" (not "delete and archive") with Mailchimp's API v3?

 September 06, 2022     mailchimp, mailchimp-api-v3.0, node.js     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing