Use the following API to add information of multiple contacts to a selected list. We already have discussed the following two options of adding contacts/subscribers through API requests.
With this particular API, you would be able to use an array to add the contact details to request adding multiple contact details in one go.
Username |
The email that the account holder uses to login MUMARA |
API Token |
The API token user has generated using the API Configuration section of MUMARA, also mentioned above. |
Method |
Method being called (Post) |
Path |
Path to the API file being called ('http//www.yourdomain.com/API/addSubscriber) |
Provide a list_id as a required parameter for the system to identify the list for purpose of adding contacts information. In an array, you can provide IDs of multiple lists and next to that information you would need to add regard to the contact/subscriber. Refer to the following sample request.
Email is the mandatory field to add the contact information within Mumara. Therefore, this default email field has to be filled with correct information.
You can also add information to the additional fields like First_Name of the subscriber and Company of the subscriber, but it isn't mandatory to submit a valid request. Click the following link, and refer to the Field Details table in Add Subscriber API article to learn which fields you can add information to.
Add Subscriber
<?php
$postData = array(
array('list_id' => '16', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
array('list_id' => '16', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
array('list_id' => '16', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
);
$postData = json_encode($postData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://yourdomain.com/API/addSubscriber');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($postData)));
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
//curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'data' => $postData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'APIToken: 343b1b831067b50e308e6bf93e0f06f0', 'Login: [email protected]'));
$data = curl_exec($ch);
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
} else {
// Show me the result
print ($data);
curl_close($ch);
}
?>
A text-based response with a "Success" status will be returned upon submitting a request with the right parameters, valid endpoint, and API key. The text-based message would show you the number of contacts added to the desired list.
A text based response providing the reason of the error. i.e.
{"status":"error","response":"List not available to add subscriber"}