Is there any direct way to get the last campaign sent on a Mailchimp account via Mailchimp API V3? So far the only way I found was to iterate over the campaigns and get the last one but it takes too much time. Thanks in advance.
Mailchimp API Get last campaign sent
1k Views Asked by colomborodrigo At
2
I don't think you can get only the last campaign sent using only one request, but you can achieve this by making two requests to the following endpoint
as described here. The parameters that you need are
count,status, andoffset.For the first request, set the
countparameter to 1 andstatusparameter tosent. You will get the first campaign sent, but you will also gettotal_itemsin the response body. Thetotal_itemsindicates the total number of sent campaigns in your MailChimp account regardless of the pagination and that's what you need to make the second request.For the second request, set the
countparameter to 1,statusparameter tosent, andoffsetparameter to the value oftotal_itemsabove - 1. For example if thetotal_itemsfrom the first request is 150, then you should setoffsetto 149. Setting theoffsetparameter to 149 will skip the first 149 sent campaigns. Thecampaignsfield in the response of the second request will contain the last campaign sent from your MailChimp account, which is what you're looking for. This will be much quicker than enumerating through all of the sent campaigns.