What API in mailchimp should I use to set a merge var value for a specific list member?
If I'm adding a new list member, I can use lists/subscribe to set a merge var value for that new member. However, I do not see an API to change the value if the list member already exists.
The API lists/merge-var-set sets the value for all list members. And lists/merge-var-update sets attributes for the merge var.
What is the API for setting a specific value?
In Mailchimp API v3 you can set a merge field value this way:
PUT {api_endpoint}/3.0/lists/{list_id}/members/{member_hash}
{
"merge_fields": {
"BIRTHDAY": "01/23"
}
}
Where {member_hash}
is md5 hash of member's email address.
You don't have to provide all merge fields. Mailchimp will update only those you've specified.
In APIv2, you still use lists/subscribe
, but you pass update_existing
as well. This is considerably more intuitive in APIv3, which you should use if you can, since 2.0 is officially deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With