Setting a Subscriber to Pending Status in MailChimp API v1.3
In Mailchimp API v1.3, you can set a subscriber to pending status by updating their subscription status for a specific list. Here’s how you can achieve this using the Mailchimp API:
- Retrieve Member Information: First, you need to retrieve the information of the subscriber whose status you want to change. You’ll need their unique email ID or subscriber ID.
- Update Subscription Status: Once you have the subscriber’s information, you can update their subscription status to “pending” for the desired list. You can do this by making a PATCH request to the Mailchimp API endpoint for updating a member’s status.
Here’s an example of how you can update a subscriber’s status to pending using the Mailchimp API v1.3 in a programming language like Python:
import requests
# Mailchimp API endpoint and API key
endpoint = "https://<dc>.api.mailchimp.com/3.0/lists/<list_id>/members/<subscriber_id>"
api_key = "your_api_key"
# Request headers
headers = {
"Content-Type": "application/json",
"Authorization": "apikey {}".format(api_key)
}
# Data for updating subscription status to "pending"
data = {
"status": "pending"
}
# Make a PATCH request to update the subscriber's status
response = requests.patch(endpoint, headers=headers, json=data)
# Check if the request was successful
if response.status_code == 200:
print("Subscriber status updated to pending successfully")
else:
print("Failed to update subscriber status:", response.status_code, response.json())
Make sure to replace <dc>
with your Mailchimp data center, <list_id>
with the ID of the list to which the subscriber belongs, and <subscriber_id>
with the ID of the subscriber whose status you want to update. Also, replace "your_api_key"
with your Mailchimp API key.
By making a PATCH request to the Mailchimp API endpoint with the updated status, you can set the subscriber to pending for the specified list.