How to hit the Mailchimp API

Mailchimp's Marketing API lives at https://<dc>.api.mailchimp.com/3.0, where <dc> is your data center — the suffix after the dash in your API key (e.g. us21).

Authentication

Create a key under Account → Extras → API keys. Send it as Authorization: Bearer <key>. In the examples it's written {{MAILCHIMP_API_KEY}}, and {{DC}} is the data center.

Full reference: https://mailchimp.com/developer/marketing/api/

Check your key

curl https://{{DC}}.api.mailchimp.com/3.0/ping \
  -H "Authorization: Bearer {{MAILCHIMP_API_KEY}}"
Run in PostTaco

List audiences

Mailchimp's API still calls audiences lists.

curl "https://{{DC}}.api.mailchimp.com/3.0/lists?count=10" \
  -H "Authorization: Bearer {{MAILCHIMP_API_KEY}}"
Run in PostTaco

Add a subscriber

curl -X POST https://{{DC}}.api.mailchimp.com/3.0/lists/{{LIST_ID}}/members \
  -H "Authorization: Bearer {{MAILCHIMP_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"email_address": "[email protected]", "status": "subscribed"}'
Run in PostTaco