I was using some very old code to power the "Join my mailing list" boxes on my various sites. It stopped working perfectly a while back and I've been rewriting the code to use the MailChimp 3.0 APIs instead of the MailChimp 1.3 API.

Setting it up was a lot easier than I expected. The first thing I noticed after rolling it out, however, was that users were being subscribed immediately to the mailing list without using the double opt in. Obviously this is a nightmare, despite the new MailChimp defaults. You do not ever want use single opt in.

I was using this API to add new members to a list. I pulled directly from a sample in their docs:

view plain print about
1{
2 "email_address": "urist.mcvankab@freddiesjokes.com",
3 "status": "subscribed",
4 "merge_fields": {
5 "FNAME": "Urist",
6 "LNAME": "McVankab"
7 }
8}

The reason double opt in was being bypassed was because of the status of the user. I put the status as subscribed, which is a way to tell mailchimp they already double opted in. To fix my problem, I needed to change to that pending, something like this:

view plain print about
1{
2 "email_address": "urist.mcvankab@freddiesjokes.com",
3 "status": "pending",
4 "merge_fields": {
5 "FNAME": "Urist",
6 "LNAME": "McVankab"
7 }
8}

The API assumes that subscribed means they are in, but pending means they still need to approve the sign up. More details on the user statuses are on the same page with information about managing subscribers, but sadly not mentioned on the API Doc page.

I'm surprised how easy it was to set up the API Integration, so Kudos to MailChimp for that. I wish the API Docs were more detailed on the meaning and values of certain fields.