22

Using the Mailchimp API, I unsubscribed a user of a list. Then I immediately send a new request to resubscribe the same user using the Mailchimp API.

I got 400 error bad request with this message:

(...) as signed up to a lot of lists very recently; we're not allowing more signups for now

How long will I wait for a new query?

How to fix this?

Kos
  • 4,890
  • 9
  • 38
  • 42
Promo
  • 707
  • 9
  • 26
  • 1
    This always causes me trouble when developing with the API, I'd love to know the answer – Martin Hansen Lennox Mar 16 '17 at 13:38
  • I think the answer is "you can not resubcribe immediately after unsubscribe" :) – Promo Mar 17 '17 at 15:13
  • I'm ok when doing it one or two times. After a while I must hit some kind of threshold... then it seems to last for a good few days in my experience. – Martin Hansen Lennox Mar 18 '17 at 18:05
  • I'm getting the same message even for new unique addresses like xxx+1234@gmail.com – Dobes Vandermeer Jul 03 '17 at 22:47
  • @DobesVandermeer FYI Mailchimp (and all ESPs) know that this is not a unique address and is instead an alias for xxx@gmail.com, so they usually normalize before applying rate limits – Matthew Rathbone Jan 23 '18 at 15:51
  • The throttling makes sense in production but [since they have no sandbox](https://stackoverflow.com/questions/31055687/does-mailchimp-have-a-sandbox-api-with-dummy-data-in-it-for-testing) it is quite annoying since I seem to be frequently hitting this wall during testing. – But those new buttons though.. Dec 07 '22 at 20:19

3 Answers3

18

tl;dr

Retry after 5 minutes, 1 day after that, 2 days after that, and 7 days after that.


The (way too) long version

We ran into this issue as well with a large number of subscribes, with this (unhelpful) response:

HTTP 400 Bad Request
Server: openresty
Content-Type: application/problem+json; charset=utf-8
Content-Length: 301
X-Request-Id: {requestId}
Link: <https://us14.api.mailchimp.com/schema/3.0/ProblemDetailDocument.json>; rel="describedBy"
Date: {date}
Connection: close
Set-Cookie: _AVESTA_ENVIRONMENT=prod; path=/
{
    "type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
    "title": "Invalid Resource",
    "status": 400,
    "detail": "{email} has signed up to a lot of lists very recently; we're not allowing more signups for now",
    "instance": "{instance}"
}

The linked error glossary isn't much help either:

400

BadRequest

Your request could not be processed.

This is a generic error.

Let the experimentation begin!

We switched from directly calling the MailChimp API to saving all subscribe requests in our database (which, I admit, we should have been doing all along). This table looks something like:

CREATE TABLE `subscribes` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `email` varchar(254) NOT NULL,
  `json` varchar(500) NOT NULL,
  `subscribed` datetime NOT NULL,
  `ip` int(10) unsigned NOT NULL,
  `retry` datetime DEFAULT NULL,
  `attempts` int(11) DEFAULT 0,
  `synced` datetime DEFAULT NULL,
  `failed` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `unsynced` (`synced`,`failed`,`retry`,`id`)
);

We then set up a cron job to periodically check for subscribes that need to be synced with a query like this:

SELECT `id`
FROM `subscribes`
WHERE `synced` IS NULL
AND `failed` IS NULL
AND (`retry` IS NULL OR `retry` < UTC_TIMESTAMP())

For each subscribe, attempts is incremented. If the subscribe works, synced is updated with the current timestamp. Otherwise, retry is set to a date in the future based on the value of attempts, or failed is set to the current timestamp if we have run out of attempts.

Out initial set of delays (after the most recent attempt) are as follows:

  • 5 minutes
  • 1 hour
  • 6 hours
  • 1 day
  • 2 days
  • 7 days

For a subscribe to be fully retried with these delays, it would take 10 days, 7 hours, and 5 minutes.

We're currently only about 3 weeks into the test, but it's produced useful results, so I figured I'd post here now:

after last | after first | % subscribed
-----------|-------------|-------------
-          | -           | 73.45%
5 minutes  | 5m          | 73.61%
1 hour     | 1h 5m       | 73.61%
6 hours    | 7h 5m       | 73.61%
1 day      | 1d 7h 5m    | 78.43%
2 days     | 3d 7h 5m    | 96.15%
7 days     | 10d 7h 5m   | 99.49%

The shorter delays can help work around network errors or temporary issues with MailChimp api (which are fairly uncommon), while the longer delays (1 day and longer) work around the "not allowing more signups for now" issue. There were still a small number of subscribes that "succeeded" and marked as "cleaned" in MailChimp, but that's to be expected and the vast majority were subscribed successfully.

My (unofficial) recommendation

How long will I wait for a new query ? How to fix this ?

I'd suggest running your own tests to see what works for you! But, if you just want to get something out the door that has worked for others:

I'd suggest retrying after 5 minutes, 1 day after that, 2 days after that, and 7 days after that. Possibly again after that to catch that additional .51% of subscribes, but I don't have data to verify that it would work.

5 minute delay resulted in .16% more people subscribed. This helps to subscribe someone in time for an email that is going to be sent out soon, which avoids "I signed up but didn't receive the newsletter" complaints. This didn't catch many subscribers for us, but for those times that the MailChimp api (or somewhere along the network) has a short outage, this is nice to have.

1 and 6 hour delays didn't do anything for us, so it's probably not necessary. But results may vary. Again, this would be more for short outages, so you don't really know the best delay until it happens. Decide what fits your needs best and go with that.

1 day delay got more than 4.7% more people subscribed (~11% of retries succeeded). This will get the person subscribed the next day if there was a network or MailChimp api issue on the day they tried to subscribe. I would recommend.

2 day delay resulted in more than 17.72% more people subscribed (~80% of retries succeeded). Definitely recommended.

7 day delay resulted in another 3.34% subscribed (~80% of retries succeeded). Recommended.

Note: We have yet to test 1, 2, and 7 day delays on their own. It could be that on their own, they aren't that useful, but stacked together is why they succeed (eg, 2 day delay fails, but a delay of 3 days 7 hours and 5 minutes works).

0b10011
  • 18,397
  • 4
  • 65
  • 86
6

This error message is related to a throttle that Mailchimp have in place to prevent spammers from inundating audiences with fake signups. When Mailchimp system recognizes that an email address is being added to a large number of audiences within a small window of time (or a variant of the address like with these alias addresses), we will throttle signup activity for that email address for up to 48 hours. This is response from support. you would have to wait for 48 hours to excldue that email, or you can use different email, or you can dd it from Mailchimp Add audience

user838900
  • 109
  • 1
  • 2
1

This is weird kind of rate limiting that Mailchimp had put up. It happens when you generally trigger email with xyz@example.com, xyz+1@example.com, xyz+2@example.com . They do rate limiting and requests throttle.

You generally will have to wait for certain window size (in this case 48 hours).

NIshank
  • 97
  • 6