Mailchimp api tags

Mailchimp's API allows you to manage tags, which are keywords or labels that you can assign to subscribers to help you segment and target your audience. Here are some common use cases for tags in Mailchimp's API:

Creating a tag

To create a new tag using the Mailchimp API, you can use the POST /tags endpoint. The request body should contain the following information:

Example request:

{
  "name": "New Tag",
  "description": "This is a new tag"
}

Retrieving a list of tags

To retrieve a list of all tags in your Mailchimp account, you can use the GET /tags endpoint.

Example request:

GET https://us12.api.mailchimp.com/3.0/tags

The response will contain a list of tags, each represented by a JSON object with the following properties:

Assigning a tag to a subscriber

To assign a tag to a subscriber, you can use the POST /lists/{list_id}/members/{member_id}/tags endpoint. The request body should contain the following information:

Example request:

{
  "tag_id": "123456"
}

Removing a tag from a subscriber

To remove a tag from a subscriber, you can use the DELETE /lists/{list_id}/members/{member_id}/tags/{tag_id} endpoint.

Example request:

DELETE https://us12.api.mailchimp.com/3.0/lists/{list_id}/members/{member_id}/tags/123456

Retrieving a list of subscribers with a specific tag

To retrieve a list of subscribers who have a specific tag, you can use the GET /lists/{list_id}/members/search endpoint with the search_fields parameter set to tags.

Example request:

GET https://us12.api.mailchimp.com/3.0/lists/{list_id}/members/search
?search_fields=tags
&query=New+Tag

The response will contain a list of subscribers who have the specified tag.

Other tag-related endpoints

Here are some other endpoints related to tags in Mailchimp's API:

Note that you need to replace {list_id} and {member_id} with the actual IDs of your Mailchimp list and subscriber, respectively.