Knowledgebase

Add Subscriber

The section describes the Json document formation for adding a subscriber to a list; with the details of the fields you can add information to, a sample request and its responses at the end of this section.

Required to Submit Json Request

Username

The email that account holder uses to login MUMARA

API Token

The API token user has generated using 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/deleteSubscriber)

Throughout this API document, required fields are mentioned as required under priority column of the Field Details Table. While for the non-required fields, priority column remains empty. The second column of the table "Variables" shows the variables that you will use in an API request to parse the values of the respective fields. 

Field Details 

Label

Variable

Priority

Description

 Email

['email']

Required

Email Address of the Subscriber you need to add

List ID

['list_id']

Required

List ID of the subscriber list where you want to add subscriber information to

Title

['title']

Optional 

Professional title, designation of the subscriber such as COO, CIO, CMO etc

First Name

['first_name']

Optional 

First Name of the Subscriber you want to add to the list

Last Name

['last_name']

Optional 

Last Name of the Subscriber you want to add to the list

Unsubscribed

['unsubscribed']

Optional 

Had the subscriber been marked as “Unsubscribed”? If yes then set this field with “1” while sending API request for adding subscriber information to a list. Otherwise, proceed with “0” which sets this subscriber status as default “Subscribed” within the list.

Bounced

['bounced']

Optional 

Had the subscriber been marked as “Bounced”? If yes then set this field with “1” while sending API request for adding subscriber information to a list. Otherwise, proceed with “0” which sets this subscriber status as default “Not Bounced” within the list.

Create Date

['create_date']

Optional 

 

FORMAT

['FORMAT']

Optional 

What essential email format subscriber prefers to receive, HTML/ Text (h for HTML and t for Text emails)

Confirmation Status

['confirmation_status']

Optional 

Indicates the confirmation status of the subscriber, confirmed or not. Set this field with “1” to mark the subscriber status as “Confirmed” or proceed with “0” in case subscriber has not been confirmed yet.

City

['city']

Optional 

Which city subscriber belongs to

Country

['country']

Optional 

Which country subscriber belongs to

Company

['company']

Optional 

Which company subscriber works in

Post Code

['post_code']

Optional 

Post Code information of the subscriber current location

State

['state']

Optional 

Which state subscriber belongs to

Mobile

['mobile']

Optional 

Mobile phone number of the subscriber

Phone

['phone']

Optional 

Phone number of the subscriber

Fax

['fax']

Optional 

Information of the subscriber to add into the Fax field

Sample Request

The following sample request adds a subscriber with email [email protected], having list ID “128” and other related information like First Name- Robert and Last Name- Daniel. The sample request uses CURL function of PHP.

$postData['list_id']    = '128';
$postData['email']      = '[email protected]';
$postData['first_name'] = 'Robert';
$postData['last_name']  = 'Daniel';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http//www.yourdomain.com/API/addSubscriber');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $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);
}

Adding Multiple Subscribers

$postData = array(
array('list_id' => '3', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
array('list_id' => '3', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
array('list_id' => '3', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
array('list_id' => '3', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname'),
array('list_id' => '3', 'email' => '[email protected]','first_name' => 'fname', 'last_name' => 'lname')
);

$postData = json_encode($postData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://www.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_POSTFIELDS, array( 'data' => $postData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'APIToken: MUMARA_TOKEN', 'Login: [email protected]'));

$data = curl_exec($ch);
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
} else {
print ($data);
curl_close($ch);
}

Success Response

The required subscriber and other related information will be added to the list upon submitting valid information appropriately, as a result of successful submission, Json based response will return the ID of newly added subscriber as in the following sample response.

Status value for successfully added subscriber will be- “success”
Data Returned-"Subscriber ID"
Following is the example of a success response.

{"status":"success","response":{"Subscriber ID":"20"}};

Erroneous Response

When you submit request with inappropriate, incorrect information.

Status value for unsuccessful submission will be-"error”
Data Returned- Text based message describing reason of unsuccessful response
Some erroneous responses are as follows.

{"status":"error","response":"Email already exists in this List."}
{"status":"error","response":"List not available to add subscriber"}
{"status":"error","response":"Email is required to add subscriber"}
{"status":"error","response":"List ID is required to add subscriber"}