Reputation: 549
I'd like to know if the Mailchimp API v3.0 allows for the EMAIL address to be changed for a subscriber.
This is what I have:
$email = strtolower(trim($oldEmail));
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
return false;
}
$emailHash = md5($email);
$result = $this->patch('/lists/'.$listid.'/members/'.$emailHash,
array(
'email_address' => $oldEmail,
'merge_fields' => array("EMAIL" => $newEmail),
'status' => "subscribed",
));
And it doesn't work. Mailchimp returns the usual GET MEMBER response, and shows that nothing has been changed.
Any idea?
Thank you, Riccardo
Upvotes: 20
Views: 10576
Reputation: 21
of course you can update email address, use
PATCH /lists/{list_id}/members/{hashed_old_email_address}
and set the new email address in the payload https://mailchimp.com/developer/marketing/api/list-members/update-list-member/
Upvotes: 0
Reputation: 28968
According to MailChimps changelog changing the email of a user is possible since 3rd of November 2016 with patch and put.
11/03/2016
Add the ability to update an existing list member’s email_address through a PATCH or PUT call to /lists/{list_id}/members/{subscriber_hash}
You do not need to use merge_field to change the email. You can simply do it like this:
$emailHash = md5($oldEmail);
$result = $this->patch('/lists/'.$listid.'/members/'.$emailHash,
array(
'email_address' => $newEmail,
'status' => "subscribed",
));
Upvotes: 10
Reputation: 176
I know that this is a bit late but right now the PUT
method (.../3.0/lists/{listId}/members/{md5}
) allows to change the email address.
I'm sending the new email in the body and MERGE0 (EMAIL) tag but using the md5 from the previous email. It is changing the email correctly.
Upvotes: 14
Reputation: 1687
According to the docs, it does. It does not work on our side either, so we'll contact Mailchimp to know the reason why it's in the doc.
EDIT: It is indeed not possible, the documentation was outdated. Here is what mailchimp had to say about this:
Hi Philipp, Thanks for reaching out to MailChimp support with those API concerns, and for allowing us to assist. With MailChimp version 3.0, users cannot update a subscriber email address. While this may have been available with past versions of our API, it is no longer supported. To update a subscriber email address, the best move will be to manually update from within MailChimp. Each email address is considered to be a unique identifier for list members. I can certainly understand how the documentation can be a bit misleading, and you do have the ability to update subscriber fields in the list, however email address is not one of them. This is why you have not seen that information updated in MailChimp. I will be reviewing the documentation on this end, and making suggestions to have that article edited if indeed we are suggesting that email addresses can be updated using API. Thanks for this feedback, and for hanging in with us. We appreciate your time, energy and patience as we reviewed things on our end. Thank you again for choosing MailChimp, and keep us posted with any other questions that you may have moving forward.
Upvotes: 10
Reputation: 4643
No, MailChimp doesn't really allow email addresses to be changed. You can do it in the web app, but almost all stats and activity information don't carry over. API v3.0 doesn't support changing email addresses at all for that reason. What you want to do is unsubscribe or delete the old address and then re-create the new one.
Upvotes: 4