diff --git a/lib/mailchimp/MailChimpAPI_v2_0.js b/lib/mailchimp/MailChimpAPI_v2_0.js index 2d0af3b..36225d0 100644 --- a/lib/mailchimp/MailChimpAPI_v2_0.js +++ b/lib/mailchimp/MailChimpAPI_v2_0.js @@ -1,6 +1,6 @@ var http = require('http'), - request = require('request'), - helpers = require('./helpers'); + request = require('request'), + helpers = require('./helpers'); /** * MailChimp API wrapper for the API version 2.0. This object should not be @@ -15,6 +15,11 @@ function MailChimpAPI_v2_0 (apiKey, options) { if (!options) var options = {}; + // API Key must look like abc123-us2 (where us2 is the data center) + if (!apiKey.match(/^[a-z0-9]*\-[a-z0-9]*$/)) { + throw new Error('Unrecognized API key format: ' + apiKey + '. should look more like abc123-us2.'); + } + this.version = '2.0'; this.apiKey = apiKey; this.packageInfo = options.packageInfo;