Mailchimp API adding tags to existing members

You can add tags to current mailing list subscribers using Mailchimp’s API. Here’s an illustration of how to tag an existing user using the Mailchimp API:

To begin, send a POST request to the `lists/{list_id}/members/{subscriber_hash}/tags` endpoint. The list_id is the mailing list’s unique identifier, and the subscriber hash is the MD5 hash of the subscriber’s email address in lowercase.

You must include the name of the tag you want to add in the request body. As an example,

{
  "tags": [
    {
      "name": "Gold",
      "status": "active"
    }
  ]
}

To make this request, you will need an API key, which you can find in your Mailchimp account under account settings.

You can also include an array of tags in the request body to add multiple tags at once, for example:

{
  "tags": [
    {
      "name": "Gold",
      "status": "active"
    },
    {
      "name": "Silver",
      "status": "active"
    }
  ]
}

It’s important to note that you can only add tags to mailing list members who have the “subscribed” status. You’ll get an error if you try to add a tag to a member who has a different status.

Here is an example of a cURL API request for adding tags to an existing member:

curl --location --request POST 'https://us19.api.mailchimp.com/3.0/lists/fgdrtf/members/dfgf3cef280454550ec978c8bsd435/tags' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "tags": [
        {
            "name": "Gold",
            "status": "active"
        },
        {
            "name": "Silver",
            "status": "active"
        }
    ]
}'