Using Bulk Add Contacts with JSON Example

Frequent Participant

Using Bulk Add Contacts with JSON Example

I have been trying to figure out how to use the bulk activities add contacts api for quite sometime now and just recently figured out how to actually do it correctly. I could find very little help with what I was doing, so I figure it might help someone with a similar problem as mine to have an example of how to use with JSON, PHP, and curl with a JSON POST script.



$user = '{
$access_token = 'ACCESS TOKEN';
    $url = ' KEY';
    // Start curl.
    $ch = curl_init();
    // Set query data here with the URL
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_HTTPHEADER,array('Authorization:Bearer ACCESS TOKEN', 'Content-Type:application/json'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, '30');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $user);
    $content = curl_exec($ch);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

The formatting of the JSON is very particular so I suggest you run it through to be sure you are passing in a valid JSON string.


Hopefully this example saves someone some time.


Thanks for the code snippet post, I'm sure someone will be very greatful for this!  Always great to see the community contributing back like this.  Let us know if you run into anything else in the future, we're here to help if you have questions or run into a roadblock.


On another note, we have a PHP wrapper update coming soon that will include all the different options for bulk import, include the different file types and JSON.  You can find this wrapper and all updates here:

Dave Berard
Senior Product Manager, Constant Contact
Occasional Participant



I'm trying to Bulk Add Contacts but the problem i have is that the lists the various contacts are subscribing to varies.

In other words not everyone is being added to the same lists. The sample code seems to imply that all contacts being added in bulk are for the same lists.


Is there anyway this can be handled in one Bulk Add or would it need to be split according to the lists they should all be added to? I'm trying to avoid having to create a large number of requests as i don't want to have problems with the 4 requests per second limitation.


Thanks in advance


Hi Enrique,


With Bulk Imports all of the contacts that are included in the import will be assigned to all lists that are included in the import. Since these imports are treated as an add+update operation, they will only add and update information that is present in the import and will not remove/delete any information from the contacts, including list memberships.


Given the above, it might be most effective for your situation to create one import per list that needs to have contacts added. For this you would group all of the contacts that will be added to list A, and create an import with those contacts that specified list A. Then you would do the same for List B, List C, and so on. Once these imports have completed, then any contacts who were part of multiple imports will have the desired list memberships. This would limit the number of requests that need to be made (which should make it easy to remain under 4 calls/second) while still providing a relatively direct way to get all of the contacts uploaded.


If you have any questions, please let us know!



Elijah G.
API Support Engineer
Occasional Participant

Hi Elijah


Thanks for your reply - really appreciate it. Ok, what you suggest is what i feared you would say :-)


Ok, i will proceed with this approach and let you know if i run into problems.




Developer Portal

View API documentation, code samples, get your API key.

Visit Page