Knowledgebase

Add a Contact

Method: POST
Endpoint: /api/addContact

Parameters

Parameter Type Required

Description

email string Yes Email address of the contact
list_id int Yes id of the contact list where this contact will be added
format TEXT, HTML (default: HTML) No Which format this contact should receive the email

HTML = Will receive HTML version of the email
TEXT = WIll receive simple text version
is_confirmed 0, 1 (default: 1) No Confirmation status of the contact

0 = Add this contact as unconfirmed
1 = Add this contact as confirmed
is_active 0, 1 (default: 1) No Status of the contact

0 = Mark as inactive (will not receive emails)
1 = Mark as active
bounced 0, 1, 2 (default: 0) No Bounced status of the contact
0 = Add as not bounced
1 = Add as soft bounced
2 = Add as hard bounced
is_unsubscribed 0, 1 (default: 0) No Subscription status of the contact

0 = Mark as subscribed
1 = Mark as unsubscribed
is_spam 0, 1 (default: 0) No If this contact has produced a spam complaint

0 = Mark as spam
1 = Don't mark as spam
additional_field string No Add details to additional fields
response 0, 1 (default: 0) No Get full response of the operation


Response Parameters

Parameter Type Description
status JSON Success or Error
result JSON Result of the operation
response JSON Output of the operation


Example Request (CURL)

<?php
// Authentication
$api_token	=	'API_KEY'; // Mumara API Key (can be found in Settings -> API Key)
$domain		=	'http://www.anydomain.com'; // Your Mumara Domain Name

// API Endpoint
$endpoint	=	'/api/addContact';

//Parameters
$params = [
    'list_id'           =>  '9',
    'email'             =>  '[email protected]',
    'first_name'        =>  'Anthony',
    'company'           =>  'Tstore',
    'is_confirmed'      =>  '1',
    'is_active'         =>  '1',
    'is_unsubscribed'   =>  '1',
    'last_name'         =>  'Lewis',
    'response'          =>  '1',
];

// Defining cURL Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$domain.$endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER,
    array('Content-Type: application/json', 'Authorization: Bearer ' . $api_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Executing cURL
$output = curl_exec ($ch);

// Printing Output
echo "<pre>";
echo json_encode(json_decode($output),JSON_PRETTY_PRINT );

// Closing cURL
curl_close ($ch);
?>


Example Response (JSON)

 {
    "status": "success",
    "result": "Success: Contact has been successfully created.",
    "response": {
        "id": 44,
        "email": "[email protected]",
        "list_id": 9,
        "bounced": "no_process",
        "is_spamed": 0,
        "is_unsubscribed": 1,
        "is_confirmed": 1,
        "is_verified": 0,
        "is_active": 1,
        "format": "html",
        "user_id": 2,
        "created_at": "2019-05-15 08:38:46",
        "updated_at": "2019-05-15 08:38:46",
        "additional_fields_data": {
            "first_name": "Anthony",
            "company": "Tstore",
            "last_name": "Lewis"
        }
    }
 }
Status value of the success response will be "success"


Example Error Response (JSON)

 {
    "status": "error",
    "result": "Error: Email address already exists"
 }


Possible Errors

  • Invalid format
  • Invalid contact list id
  • Access Denied
  • Email address already exists
POST
/api/addContact
Try it out