Overview

You can use this request to create many contacts at once. This request is similar to the Create Contacts in Bulk method, but it runs the contact creation asynchronously.

Once you make the request, we will store the data you have sent and immediately give you a response saying that the data is stored. Then the data will be processed on our side without you having to wait for it to be done within the scope of the API request. Because of this, it should allow for a lot more contacts to be sent at once, whereas bulk create is limited to 2,000 at a time.

The Method

TypeRequestMethod
RESTPOSThttps://[Your URL]/api/2.0/contacts/import
XML-RPCCallcontacts.ListContacts

Your method must be structured as follows:

Parameters

Required Parameters

The $contacts function must be passed as an array of contacts.

As with creating single contacts, you must create a new contact with either an email address or a mobile phone number. You must also specify the lists the contact will belong to, and their subscription status.

PropertyTypeDescriptionDefaultRequiredRead Only
list_idarrayAn array of list IDs with the subscription status for the contact. For example:
array(1 => ‘unconfirmed’, 2 => ‘subscribed’)
will subscribe the contact to list with ID 2, and add the contact as an unconfirmed contact to list 1.
emptyyesno
emailstring Emailemptynono
mobilestringMobileemptynono
Optional Parameters

You may include any of these optional parameters when adding a contact:

PropertyTypeDescriptionDefaultRequiredRead Only
country_idintegerCountry identifier1nono
city_idintegerCity identifier1nono
namestringFirst Nameemptynono
last namestringLast Nameemptynono
statusstringStatus
Possible values:
on / off / suppressed
onnono
preferred_email_formatstringEmail format
Possible values:
html / text
HTMLnono
titlestringTitleemptynono
company_positionstringPositionemptynono
company_namestringCompany Nameemptynono
departmentstringDepartmentemptynono
industrystringIndustryemptynono
addressstringAddressemptynono
citystringCityemptynono
countrystringCountryemptynono
statestringProvince / Stateemptynono
zipstringPostal / ZIP codeemptynono
telephone_officestringWork Numberemptynono
telephone_homestringHome Numberemptynono
telephone_faxstringFax Numberemptynono
date_of_birthintegerDate of birth
(deprecated)
emptynono
tags  stringJSON array containing tag names emptynono
birth_datestringDate of birthemptynono
genderstringGender
Possible variables:
unknown / male / female
emptynono
marital_status stringMarital status
Possible values:
unknown / single / married
emptynono
education_levelstringEducation levelemptynono
hashstringhash_keyemptynono
unique_idstringUnique import identifieremptynono
idintegerIDemptynoyes
date_createintegerDate createdemptynoyes
scorefloat Contact score2noyes
ratingintegerContact rating score2noyes
email_statusstringEmail status
Possible values:
none / bouncing / bounced / always send
nonenoyes
create_notificationsstringCreate notification
Possible values: yes / no
nonono
email_bounce_hard_countintegerHard email bounces0noyes
email_bounce_soft_countintegerSoft email bounces0noyes
block_bounce_countintegerConsecutive block bounces0noyes
sms_bounce_hard_countintegerHard SMS bounces0noyes
sms_bounce_soft_countintegerSoft SMS bounces0noyes
sms_bounce_consecutive_countintegerConsecutive SMS bounces0noyes
complaints_countintegerComplaints0noyes
forward_countintegerForwardsemptynoyes
invite_countintegerInvitesemptynoyes
bounce_unidentified_countintegerUnidentified bounces0noyes
autoresponder_countintegerAutoresponders0noyes
email_message_idsstringEmail message identifiersemptynoyes
sms_message_idsstring SMS message identifiersemptynoyes
email_message_countintegerEmail Messages0noyes
sms_message_countintegerSMS Messages0noyes
message_reads_inferredintegerInferred reads0noyes
message_reads_uniqueintegerUnique reads0no yes
message_link_clicksintegerLink clicks0noyes
message_link_clicks_uniqueintegerUnique link clicks0noyes

Responses

TypeDescription
arrayAn array that corresponds to the passed array, with the results. The array also contains the $batch_id string, the identifier for this import, which can be used in other API calls to check the progress of the import.

Code Samples

$json = '
{
"contacts":{
"1":{
"contact_email":"[email protected]",
"on_duplicate":"update",
"list_id":{"1":"subscribed"}
},
"2":{
"contact_email":"[email protected]",
"on_duplicate":"update",
"list_id":{"1234":"subscribed"},
"tags":["first tag name", "second tag name"]
}
}
}
';

$url = '(Your URL)/api/2.0/contacts/import';

$method = 'POST';

$cSession = curl_init();
$headers = array();
$auth = base64_encode($username . ':' . $apikey);
$headers[] = 'Authorization: Basic ' . $auth;
curl_setopt($cSession, CURLOPT_URL, $url);
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cSession, CURLOPT_HEADER, false);
curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($cSession, CURLOPT_POSTFIELDS, $json);
$headers[] = 'Content-Type: application/json';
curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($cSession);
curl_close($cSession);