How can I unarchive a member using the Mailchimp API?

Viewed 1807

I'm working with the Mailchimp API v3.0 to mutate list members.

Archiving members works without issues using the following endpoint:

DELETE /lists/{list_id}/members/{subscriber_hash}

The web-interface allows me to "unarchive" a member, reverting it back to it's previous state.

web-interface unarchive

I haven't found this functionality in the API documentation yet.

I was able to unarchive the member by using the endpoint:

PATCH /lists/{list_id}/members/{subscriber_hash}

with body:

{"status": "subscribed"}

Although this does unarchive the member, this doesn't restore the status of the member. It simply sets the status to "subscribed" as provided in the body.

I'd like restore a member to its status before archiving. If a member was subscribed before archiving, then I would like it to be subscribed after unarchiving. Similarly if a member was unsubscribed before archiving, then they should be unsubscribed after unarchiving. Similar to what the web-interface does.

When retrieving the data of an archived member the return data does not include the status before archiving.

How can I unarchive a member using the Mailchimp API? Am I overlooking something, or is this functionality missing from the API?

1 Answers

I've had contact with the Mailchimp support team and currently have a band aid solution.

Let me first add some additional info that is not provided in the documentation (this comes from my chat session with the support team):

Overall from what I'm seeing, there does not appear to be a specific method to unarchive contacts without altering their original status. However while contacts who unsubscribed on their own will not be affected by the status change, other contacts who were manually unsubscribed (by you or someone else through the account/api) they will have that updated since that is considered a type of admin action.

With the above info my current solution is to update a list member to status "subscribed". If this fails with an 400 error I assume that the member unsubscribed at their own and send another request, this time using status "unsubscribed".

So:

PATCH /lists/{list_id}/members/{subscriber_hash}
{"status": "subscribed"}

If above results in status 400 then:

PATCH /lists/{list_id}/members/{subscriber_hash}
{"status": "unsubscribed"}

This solution still leaves a lot to be desired. This effectively means you cannot unarchive list members that you've given the status "unarchived" yourself. You also have to make 2 requests for list members that unsubscribed.

I've send a feedback email suggesting to add the resource:

POST /lists/{list_id}/members/{subscriber_hash}/actions/unarchive

Which is consistent with their permanent delete list member resource.

Related