Search code examples
pythonmailchimp-api-v3.0

creating campaign from python mailchimp api


I am using mailchimp3 python api

from mailchimp3 import MailChimp

client = MailChimp(mc_api='', mc_user='')

client.campaigns.create(data={})

I want to create a campaign but unable to understand what the 'data' should be in this case. Also, I want to put HTML in the email so any help in implementing this would be great. Thanks in advance


Solution

  • Campaigns data is dict type.

    format reference: line 36:

    data = {
        "recipients": object*
        {
            "list_id": string*
        },
        "settings": object*
        {
            "subject_line": string*,
            "from_name": string*,
            "reply_to": string*
        },
        "variate_settings": object* (Required if type is "variate")
        {
            "winner_criteria": string* (Must be one of "opens", "clicks", "total_revenue", or "manual")
        },
        "rss_opts": object* (Required if type is "rss")
        {
            "feed_url": string*,
            "frequency": string* (Must be one of "daily", "weekly", or "monthly")
        },
        "type": string* (Must be one of "regular", "plaintext", "rss", "variate", or "absplit")
    }