ICTBroadcast automated dialer, Using REST based APIs to automate your business process

ICTBroadcast uses REST based API to ensure communication and automation between our products and third party applications is a seamless and simple process. Customers can make the most of third party applications without compromising the quality of service ICTBroadcast provides.

“ICTBroadcast” SP Edition v2.0

“REST API User Guide”

Thank you for purchasing ICTBroadcast. If you have any questions that are beyond the scope of this help file, please feel free to email via contact form here. Thanks so much!

Table of Contents

  1. Overview
  1. Account APIs

1) Overview – top
REST API provides external interface to call some important functions of ICTBroadcast. Let’s say that we are building an application that we want to automatically upload a recording file and then create a campaign to broadcast to a contact group using ICTBroadcast APIs.
Authentication and Preparing Request
Every REST API call requires authentication before calling the web service method. Following function is used by clients to authenticate requests to the REST API. It will also prepare the request and carry the request to REST Web Service. It has two arguments. First argument is the name of the API method, where as second argument takes an array containing the input data to the method. In next section, concrete examples are given to demonstrate how to prepare arguments and then call this function.
Note: for security using SSL is recomemded while using APIs.

function broadcast_api($method, $arguments = array()) {
// update following with proper access info
$api_username = ‘myuser’; // <=== Username at ICTBroadcast
$api_password = ‘mysecret’; // <=== Password at ICTBroadcast
$service_url = ‘http://yourwebsite.com/rest’; // <=== URL for ICTBroadcast REST APIs

$post_data = array(
‘api_username’ => $api_username,
‘api_password’ => $api_password
);
$api_url = “$service_url/$method”;
$curl = curl_init($api_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
foreach($arguments as $key => $value) {
if(is_array($value)){
$post_data[$key] = json_encode($value);
} else {
$post_data[$key] = $value;
}
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
// enable following line in case, having trouble with certificate validation
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$curl_response = curl_exec($curl);
curl_close($curl);
return json_decode($curl_response);
}

Role and Permissions
By default ICTBroadcast check user permissions before executing each API request, to confirm if given user (account being used as api_username) is valid and have proper rights to perform that specific action. Even each API has unique permission requirement but usually we can divide ICTBroadcast APIs in two main groups, Administrative APIs and User APIs
Following APIs require administrative rights, In client application we need to use “admin” account as api_username

  1. User APIs
  2. DID APIs
  3. AccessNumber APIs

Following APIs can be executed by any valid ICTBroadcast user

  1. Account APIs
  2. Campaign APIs
  3. Contact APIs
  4. Recording APIs
  5. Text APIs
  6. Template APIs

2) Voice Broadcasting Campaign using APIs – top
This example creates voice recording, then creates a contact group and adds contacts in the contact group. Then finally we’ll create and run campaign.
1. First, we will need to upload the recording file.

$arguments = array(
‘title’ => ‘myrecording’,
‘media’ => ‘@test/texi.wav’,
);
$result = broadcast_api(‘Recording_Create’, $arguments);
$recording_id = $result[1];

2. Next, we will need to create a contact group.

$arguments = array(‘contact_group’=> array(‘name’ => ‘mygroup’));
$result = broadcast_api(‘Contact_Group_Create’, $arguments);
$group_id = $result[1];

3. Next, we will need to add contact to above contact group.

$contact = array(‘phone’ => ‘188887212’);
$arguments = array(‘contact’=>$contact, ‘contact_group_id’=> $group_id);
$result = broadcast_api(‘Contact_Create’, $arguments);
$contact = $result[1];

4. Finally, we will create a campaign that will broadcast our recording file (created in step 1) to contacts (created in step 2 &3).

$campaign = array(
‘contact_group_id’ => $group_id,
‘message’ => $recording_id,
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_Create’, $arguments);
$campaign_id = $result[1];
print_r(“Campaign created successfully with ID: ” . $campaign_id);

So the final code that will create a campaign to dial a contact 188887212 will look like:

<?php
$arguments = array(
‘title’ => ‘myrecording’,
‘media’ => ‘@test/texi.wav’,
);
$result = broadcast_api(‘Recording_Create’, $arguments);
$recording_id = $result[1];
$arguments = array(‘contact_group’=> array(‘name’ => ‘mygroup’));
$result = broadcast_api(‘Contact_Group_Create’, $arguments);
$group_id = $result[1];
$contact = array(‘phone’ => ‘188887212’);
$arguments = array(‘contact’=>$contact, ‘contact_group_id’=> $group_id);
$result = broadcast_api(‘Contact_Create’, $arguments);
$contact = $result[1];
$campaign = array(
‘contact_group_id’ => $group_id,
‘message’ => $recording_id,
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r(“Campaign created successfully with ID: ” . $campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}

function broadcast_api($method, $arguments = array()) {
$api_url = ‘http://yourwebsite.com/rest’;
$api_username = ‘myuser’;
$api_password = ‘mysecret’;
$service_url = “$api_url/$method?api_username=$api_username&api_password=$api_password”;
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
foreach($arguments as $key=> $value) {
if(is_array($value)){
$arguments[$key] = json_encode($value);
}
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $arguments);
$curl_response = curl_exec($curl);
curl_close($curl);
return json_decode($curl_response);
}
?>

3) List of available REST APIs – top
Following are REST API methods, arguments required by these methods and how to call these methods from client script. For all these methods, authentication and request preparation will be performed by broadcast_api() function that is defined at the start of this document. This should be available while calling any of the following methods.

a) Account – top
Following are a set of REST APIs that are user account specific. These APIs allows to update user password and sessions. Complete list is given below:
i. Account_Password_Update
ii. Account_Session
iii. Account_Session_Destroy

i) Account_Password_Update – top
This function update user password in ICTBroadcast.
Input Parameters
newpass: optional, new password for the user.
pincode: optional, new pin code for the user.
Output
Returns json encoded string containing true and success message if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘usr_id’ => 5, ‘newpass’ => ‘newpass’, ‘pincode’ => ‘2342’);
$result = broadcast_api(‘Account_Password_Update’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) Account_Session – top
This function initiate a new session in ICTBroadcast and then return its ID. later this ID can be used for authentications, like for single sign-on
Input Parameters
login_user: optional, usernmae of account, session need for.
login_pass: optional, password. Note: not optional if above parameter (username) is provided
Output
Returns json encoded string containing true and Session ID if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘login_user’ => ‘myuser’, ‘login_pass’=> ‘newpass’);
$result = broadcast_api(‘Account_Session’, $arguments);
if($result[0] == true) {
print_r($result[1]);
$session_id = $result[1];
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

iii) Account_Session_Destroy – top
This function delete a session from ICTBroadcast, can be used to log off an active user.
Input Parameters
session_id: Session id of active user.
Output
Returns json encoded string containing true and success message if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘session_id’ => ‘2342’);
$result = broadcast_api(‘Account_Session_Destroy’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

b) Campaign – top
Following are a set of REST APIs that are campaign specific. These APIs allows to create campaign, get campaign status, start campaign, stop campaign, campaign summary etc.
i. Campaign_Status
ii. Campaign_Start
iii. Campaign_Schedule
iv. Campaign_Stop
v. Campaign_Delete
vi. Campaign_Contact_Create
vii. Campaign_Summary
viii.Campaign_List_Summary
ix. Campaign_Result
x. Campaign_AMD_DNC
xi. Campaign_Create
xii. Campaign_IVR_Create
xiii.Campaign_AppointmentReminder_Create
xiv. Campaign_Interactive_Create
xv. Campaign_Fax_Create
xvi. Campaign_SMS_Create
xvii.Campaign_Email_Create

i) Campaign_Status – top
This function returns the status (e.g. running, scheduled, completed etc) of the campaign whose ID is given.
Input Parameters
campaign_id: ID of the campaign whose status is required
Output
Returns json encoded string containing campaign status data if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id);
$result = broadcast_api(‘Campaign_Status’, $arguments);
if($result[0] == true) {
$status = $result[1];
} else {
$status = ‘Campaign not found’;
}
print_r($status);
?>

ii) Campaign_Start – top
This function starts a campaign whose ID is given.
Input Parameters
campaign_id: ID of the campaign that is to be started
Output
Returns json encoded string containing true and message string if successful. In case of any failure, it will return false and failure message.
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id);
$result = broadcast_api(‘Campaign_Start’, $arguments);
print_r($result[1]);
?>

iii) Campaign_Schedule – top
This function creates schedule of a campaign whose ID is given. Campaign should be in pending state for successful creation of schedules.
Input Parameters
campaign_id: ID of the campaign that is to be started
weekdays: Comma separated values for weekdays. Values range from 1 (for sunday) to 7 (for saturday)
start_time: Associative array containing hours and minutes
stop_time: Associative array containing hours and minutes (optional argument)
Output
Returns json encoded string containing true and message string if successful. In case of any failure, it will return false and failure message.
Sample Code

<?php
$arguments = array(
‘campaign_id’ => $campaign_id,
‘weekdays’ => ‘1,2,3,4,5’, // 1 (for sunday) to 7 (for saturday)
‘start_time’ => array(‘hour’=>10, ‘minute’=>40), // sets start_time = 10:40am
‘stop_time’ => array(‘hour’=>18, ‘minute’=>20), // sets stop_time = 6:20pm
);
$result = broadcast_api(‘Campaign_Schedule’, $arguments);
$result = $result[1];
print_r($result);
?>

iv) Campaign_Stop – top
This function stops a campaign whose ID is given.
Input Parameters
campaign_id: ID of the campaign that is to be stopped
Output
Returns json encoded string containing true and string message if successful. In case of any failure, it will return false and failure message.
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id);
$result = broadcast_api(‘Campaign_Stop’, $arguments);
print_r($result[1]);
?>

v) Campaign_Delete – top
This function stops and deletes/removes a campaign whose ID is given.
Input Parameters
campaign_id: ID of the campaign that is to be stopped and removed.
Output
Returns json encoded string containing true and string message if successful. In case of any failure, it will return false and failure message.
Sample Code

<?php
$campaign_id = 12;
$arguments = array(‘campaign_id’ => $campaign_id);
$result = broadcast_api(‘Campaign_Delete’, $arguments);
if($result) {
$result = $result[1];
print_r($result);
}
?>

vi) Campaign_Contact_Create – top
This function adds a given contact that will be dialed by the campaign whose ID is given.
Input Parameters
campaign_id: ID of the campaign
contact: An array containing the contact data. For example, first_name, last_name, phone, email, address, description etc.
Output
Returns json encoded string containing campaign status data if successful. In case of any failure, it will return false.
Sample Code

<?php
$contact = array(
‘phone’ => ‘12345678’,
‘first_name’=>’first’,
‘last_name’=>’last’,
’email’=> ‘test@test.com’
);
$arguments = array(‘contact’=>$contact, ‘campaign_id’=>$campaign_id);
$result = broadcast_api(‘Campaign_Contact_Create’, $arguments);
if($result[0] == true) {
$contact_id = $result[1];
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

vii) Campaign_Summary – top
This function returns the summary of the campaign. It will list status (busy, congestion, no-response, failed) of each contact in the campaign.
Input Parameters
campaign_id: ID of the campaign whose summary is required
usr_id: ID of the user who owns this campaign
Output
Returns json encoded string containing campaign summary data if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id, ‘usr_id’=>$usr_id);
$result = broadcast_api(‘Campaign_Summary’, $arguments);
if($result[0] == true) {
$data = $result[1];
print_r($data);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

viii) Campaign_List_Summary – top
This is similar to Campaign_Summary but it return summary of all matching campaigns.
Input Parameters
campaign_id: ID of the campaign, leave empty of null for all
usr_id: ID of the user, if we have show campaigns from a specific user, use -1 as usr_id for campaign from all users
Output
Returns json encoded string containing list of campaigns. arrange by user and campaign id like [usr_id][campaign_id][status].
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id, ‘usr_id’=>$usr_id);
$result = broadcast_api(‘Campaign_List_Summary’, $arguments);
if($result[0] == true) {
$data = $result[1];
print_r($data);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ix) Campaign_Result – top
This function returns detail results of a campaign. Campaign summary have same set of returned data fields for all types of campaign. But this function returns all the contacts that are dialed and returns the response of that contact.
Input Parameters
campaign_id: ID of the campaign whose result is required
usr_id: ID of the user who owns this campaign. If not provided, then API authentication credentials will be used to get user id.
status: campaign status e.g. completed, stopped, pending etc. Optional parameter
Output
Returns json encoded string containing campaign result data if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id, ‘usr_id’=>$usr_id, ‘status’ => ‘completed’);
$result = broadcast_api(‘Campaign_Result’, $arguments);
if($result[0] == true) {
$data = $result[1];
print_r($data);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

x) Campaign_AMD_DNC – top
This function will return contacts that are dialed by campaign where AMD is detected or where DNC option is selected by the call recipient.
Input Parameters
campaign_id: ID of the campaign whose result is required
usr_id: ID of the user who owns this campaign. If not provided, then API authentication credentials will be used to get user id.
status: campaign status e.g. completed, stopped, pending etc. Optional parameter
Output
Returns json encoded string containing campaign result data if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘campaign_id’=>$campaign_id, ‘usr_id’=>$usr_id, ‘status’ => ‘completed’);
$result = broadcast_api(‘Campaign_AMD_DNC’, $arguments);
if($result[0] == true) {
$data = $result[1];
print_r($data);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xi) Campaign_Create – top
This function creates a message (voice) campaign. It requires a recording message and a contact group to run campaign.
Input Parameters
campaign: An array of campaign containing IDs of the message (recording_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1, // contact_group_id
‘message’ => 1, // recording_id
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xii) Campaign_IVR_Create – top
This function creates an IVR campaign. It requires an IVR and a contact group. IVR should already be created from IVR Designer and its ID be provided to this API.
Input Parameters
campaign: An array of campaign containing IDs of the message (ivr_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1, // contact_group_id
‘message’ => 1, // ivr_id
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_IVR_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xiii) Campaign_AppointmentReminder_Create – top
This function creates an appointment reminder campaign. It requires a reminder message (IVR message) and a contact group. Reminder Message should already be created from Message Designer.
Input Parameters
campaign: An array of campaign containing IDs of the message (ivrmessage_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1,
‘message’ => 1, // ivrmessage_id
‘appointment_type’ => ‘individual’, // or ‘group’
‘appointment_start_field’=> ‘1’, // or ‘2’ or ‘3’. Not required if appointment_type=group
‘reminder_schedule_time’ => ’24’, // No. of hours. Not required if appointment_type=group
‘reminder_expiry’ => ‘2’, // No. of hours. Not required if appointment_type=group
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_AppointmentReminder_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xiv) Campaign_Interactive_Create – top
This function creates an interactive campaign. It requires a recording message and a contact group to run campaign.
Input Parameters
campaign: An array of campaign containing IDs of the message (recording_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1,
‘message’ => 1, // recording_id
‘extension_key’ => ‘0’, // any value from 0 to 7
‘extension_id’ => ‘1’, // extension_id
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_Interactive_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xv) Campaign_Fax_Create – top
This function creates a fax campaign. It requires a document message and a contact group to run campaign.
Input Parameters
campaign: An array of campaign containing IDs of the message (document_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1,
‘message’ => 1 // document_id
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_Fax_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xvi) Campaign_SMS_Create – top
This function creates a SMS campaign. It requires a text message and a contact group to run campaign.
Input Parameters
campaign: An array of campaign containing IDs of the message (text_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1,
‘message’ => 1 // text_id
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_SMS_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xvii) Campaign_Email_Create – top
This function creates a Email campaign. It requires a email template message and a contact group to run campaign.
Input Parameters
campaign: An array of campaign containing IDs of the message (template_id in this case) and contact_group_id as mandatory fields. campaign array can contain following optional fields: name, contact_repeat, campaign_mode, am_action, am_message etc.
Output
Returns json encoded string containing campaign_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$campaign = array(
‘contact_group_id’ => 1,
‘message’ => 1 // template_id
);
$arguments = array(‘campaign’=>$campaign);
$result = broadcast_api(‘Campaign_Email_Create’, $arguments);
if($result[0] == true) {
$campaign_id = $result[1];
print_r($campaign_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

c) Contact – top
Following are a set of REST APIs that are contact specific. These APIs allows to create contact, delete contact, create contact group, and show contact group list.
i. Contact_Create
ii. Contact_Import
iii. Contact_Delete
iv. Contact_List
v. Contact_Group_Create
vi. Contact_Group_Update
vii. Contact_Group_List
viii. Contact_DNC_Delete
ix. Contact_DNC_List
x. Contact_DNC_Create
xi. Contact_DNC_Import

i) Contact_Create – top
This function creates a new contact in a group whose contact_group_id is provided while calling this method.
Input Parameters
contact: An array containing the contact data. For example, first_name, last_name, phone, email, address, description etc.
contact_group_id: ID of the contact group where we need to add new contact
Output
Returns json encoded string containing contact_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$contact = array(
‘phone’ => ‘12345678’,
‘first_name’=>’first’,
‘last_name’=>’last’,
’email’=> ‘test@test.com’
);
$arguments = array(‘contact’=>$contact, ‘contact_group_id’=> $group_id);
$result = broadcast_api(‘Contact_Create’, $arguments);
if($result[0] == true) {
$contact_id = $result[1];
print_r($contact_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) Contact_Import – top
This function import contact from csv file (or from existing contact group) into given contact group.
Input Parameters
contact_group_id: ID of the contact group where we want to save new contacts.
type: what is our contact source. possible values are ‘file’ and ‘group’ respectively for csv files and for existing contact groups
source_file: Path to the contact file (.csv file) preceeded by a @ sign.
Or
source_contact_group_id: Id of existing contact group from where we have to import contacts.
Output
Returns json encoded string containing true and contact count if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘contact_group_id’=> 2, ‘type’ => ‘file’, ‘source_file’=> ‘@path/contact.csv);
$result = broadcast_api(‘Contact_Import’, $arguments);
if($result[0] == true) {
$contact_count = $result[1];
print_r($contact_count);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

iii) Contact_Delete – top
This function removes a contact from all contact groups.
Input Parameters
contact_id: ID of the contact that is to be removed
Output
Returns json encoded string containing true if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘contact_id’=> $contact_id);
$result = broadcast_api(‘Contact_Delete’, $arguments);
$msg = $result[1];
print_r($msg);
?>

iv) Contact_List – top
This function lists all the contacts as per given search pattern.
Input Parameters
search: An array containing search fields and values.
Output
Returns json encoded string containing true and list of contacts if successful. In case of any failure, it will return false.
Sample Code

<?php
$search = array(’email’ => ‘@gmail.com’, ‘contact_group_id’ => 2);
$arguments = array(‘search’=> $search);
$result = broadcast_api(‘Contact_List’, $arguments);
if($result[0] == true) {
$contact_list = $result[1];
foreach ($contact_list as $contact) {
print_r($contact);
}
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

v) Contact_Group_Create – top
This function creates a new contact groups.
Input Parameters
contact_group: An array containing the contact group data. For example, name and description.
Output
Returns json encoded string containing true and contact_group_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘contact_group’=> array(‘name’ => ‘mygroup’));
$result = broadcast_api(‘Contact_Group_Create’, $arguments);
if($result[0] == true) {
$contact_group_id = $result[1];
print_r($contact_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

vi) Contact_Group_Update – top
This function creates a new contact groups.
Input Parameters
contact_group: An array containing the contact group data. For example, name and description.
Output
Returns array containing result as boolean and string members.
Sample Code

<?php
$arguments = array(‘contact_group_id’ => 1, ‘contact_group’=> array(‘name’ => ‘mygroup’));
$result = broadcast_api(‘Contact_Group_Update’, $arguments);
if($result[0] == true) {
print_r(“Group updated successfully”);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

vii) Contact_Group_List – top
This function lists all the contact groups of a user.
Input Parameters
usr_id: Optional. If not provided then usr_id provided in the authentication will be used.
Output
Returns json encoded string containing true and list of group name and id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘usr_id’=> $usr_id);
$result = broadcast_api(‘Contact_Group_List’, $arguments);
if($result[0] == true) {
$list = $result[1];
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

viii) Contact_DNC_Delete – top
This function removes (a single or multiple) DNC contacts from users DNC list.
Input Parameters
number: An array of phone numbers that is to be removed
Output
Returns json encoded string containing true and success message if successful. In case of any failure, it will return false.
Sample Code

<?php
$number = array(
‘1444444444’,
‘1888654432’,
);
$arguments = array(‘number’=> $number);
$result = broadcast_api(‘Contact_DNC_Delete’, $arguments);
$msg = $result[1];
print_r($msg);
?>

ix) Contact_DNC_List – top
This function lists all the DNC contacts as per given search pattern.
Input Parameters
search: An array containing search fields and values.
Output
Returns json encoded string containing true and list of contacts if successful. In case of any failure, it will return false.
Sample Code

<?php
$search = array(’email’ => ‘@gmail.com’);
$arguments = array(‘search’=> $search);
$result = broadcast_api(‘Contact_DNC_List’, $arguments);
if($result[0] == true) {
$dnc_list = $result[1];
foreach ($dnc_list as $contact) {
print_r($contact);
}
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

x) Contact_DNC_Create – top
This function creates a new contact in DNC / Don’t call list.
Input Parameters
contact: An array containing the dnc contact data. For example, first_name, last_name, phone, email, address, description etc.
is_global: Optional. Set to true, in case user want to edit global (system wide) dnc list instead of user dnc list. Note: only for admins
Output
Returns json encoded string containing contact_dnc_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$dnc_contact = array(
‘phone’ => ‘12345678’,
‘first_name’=>’first’,
‘last_name’=>’last’,
’email’=> ‘test@test.com’
);
$arguments = array(‘contact’=>$contact, ‘is_global’=> false);
$result = broadcast_api(‘Contact_DNC_Create’, $arguments);
if($result[0] == true) {
$contact_dnc_id = $result[1];
print_r($contact_dnc_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xi) Contact_DNC_Import – top
This function import contact into DNC list from csv file (or from existing contact group).
Input Parameters
type: what is our contact source. possible values are ‘file’ and ‘group’ respectively for csv files and for existing contact groups
source_file: Path to the contact file (.csv file) preceeded by a @ sign.
Or
source_contact_group_id: Id of existing contact group from where we have to import contacts.
is_global: Optional. Set to true, in case user want to edit global (system wide) dnc list instead of user dnc list. Note: only for admins
Output
Returns json encoded string containing true and contact count if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘type’ => ‘file’, ‘source_file’=> ‘@path/contact.csv, ‘is_global’ => false);
$result = broadcast_api(‘Contact_DNC_Import’, $arguments);
if($result[0] == true) {
$contact_count = $result[1];
print_r($contact_count);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

d) Recording – top
Following are a set of REST APIs that are recording specific. These APIs allows to create recording, show list of available recording.
i. Recording_Create
ii. Recording_List

i) Recording_Create – top
This function creates a new recording.
Input Parameters
title: Name of the recording containing just alphanumeric characters. No special characters allowed.
media: Path to the recording file (.wav file) preceeded by a @ sign.
Output
Returns json encoded string containing true and recording_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘title’=> ‘myrecording’, ‘media’=> ‘@path/name.wav);
$result = broadcast_api(‘Recording_Create’, $arguments);
if($result[0] == true) {
$recording_id = $result[1];
print_r($recording_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) Recording_List – top
This function lists all the recording of a user.
Input Parameters
usr_id: Optional. If not provided then usr_id provided in the authentication will be used.
Output
Returns json encoded string containing true and list of recording name and id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘usr_id’=> $usr_id);
$result = broadcast_api(‘Recording_List’, $arguments);
if($result[0] == true) {
$list = $result[1];
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

e) Text – top
Following are a set of REST APIs that are text specific. These APIs allows to create text for sms messages, show list of available text messages.
i. Text_Create
ii. Text_List

i) Text_Create – top
This function creates a new text message.
Input Parameters
name: Name of the text containing just alphanumeric characters. No special characters allowed.
description: some other info about message.
data: Actual text / message body.
Output
Returns json encoded string containing true and text_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘name’=> ‘mytext’, ‘description’=> ‘mytest’, ‘data’ => ‘please call back’);
$result = broadcast_api(‘Text_Create’, $arguments);
if($result[0] == true) {
$text_id = $result[1];
print_r($text_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) Text_List – top
This function lists all text messages saved by current user.
Input Parameters
usr_id: Optional. If not provided then usr_id provided in the authentication will be used.
Output
Returns json encoded string containing true and list of text name and id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘usr_id’=> $usr_id);
$result = broadcast_api(‘Text_List’, $arguments);
if($result[0] == true) {
$list = $result[1];
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

f) Template – top
Following are a set of REST APIs that are Email template specific. These APIs allows to create email templates, show list of available template.
i. Template_Create
ii. Template_Attachment_Add
iii.Template_List

i) Template_Create – top
This function creates a new template.
Input Parameters
name: Name of the template containing just alphanumeric characters. No special characters allowed.
description: some other info about email message.
subject: subject line of email.
body: email message body, possibly HTML .
body_alt: Optional: in case html in body, provide a none html version of message here.
Output
Returns json encoded string containing true and template_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(
‘name’ => ‘mytemplate’,
‘description’ => ‘my message’,
‘subject’ => ‘A test email’,
‘body’ => ‘<h1>Only a single Headline</h1>’
‘body_alt’ => ‘Only a single Headline’
);
$result = broadcast_api(‘Template_Create’, $arguments);
if($result[0] == true) {
$template_id = $result[1];
print_r($template_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) Template_Attachment_Add – top
This function attach given file with existing template.
Input Parameters
name: File Name of the attachment, full name with extention, but without any path reference.
attachment: Path to the attachment file preceded by a @ sign.
Output
Returns json encoded string containing true and template_attachment_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘name’=> ‘test.jpg’, ‘attachment’=> ‘@path/test.jpg);
$result = broadcast_api(‘Template_Attachment_Add’, $arguments);
if($result[0] == true) {
$template_attachment_id = $result[1];
print_r($template_attachment_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

iii) Template_List – top
This function lists all the template of a user.
Input Parameters
usr_id: Optional. If not provided then usr_id provided in the authentication will be used.
Output
Returns json encoded string containing true and list of template name and id if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘usr_id’=> $usr_id);
$result = broadcast_api(‘Template_List’, $arguments);
if($result[0] == true) {
$list = $result[1];
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

g) User – top
Following are a set of REST APIs that are user specific. These APIs allows to create user, update user, get user list, user login and logout, and many more. Complete list is given below:
i. User_Create
ii. User_Update
iii. User_Password_Update
iv. User_List
v. User_Get
vi. User_Delete
vii. User_Login
viii.User_Logout
ix. User_Extension_Create
x. User_Role_List
xi. User_Credit_Get
xii. User_Payment_Create
xiii.User_Payment_List
xiv. User_Permission_Create
xv. User_Permission_Delete
xvi. User_Resource_Create
xvii.User_Resource_Delete

i) User_Create – top
This function creates a new user in ICTBroadcast.
Input Parameters
user: An array containing the user data. For example, username, first_name, last_name, phone, email, address etc.
Output
Returns json encoded string containing usr_id and username if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$user = array(
‘username’ => ‘myuser’,
‘passwd’ =>’test’,
‘active’ => 1,
‘role_id’ => 2, // role_id for user
‘first_name’=> ‘Name 1’,
‘last_name’ => ‘Test 1’,
‘company’ => ‘My company’,
);
$arguments = array(‘user’=> $user);
$result = broadcast_api(‘User_Create’, $arguments);
if($result[0] == true) {
$user_id = $result[1];
print_r($user_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) User_Update – top
This function creates a new user in ICTBroadcast.
Input Parameters
usr_id: A usr_id of the user whose information is to be updated.
user: An array containing the user data. For example, username, first_name, last_name, phone, email, address etc.
Output
Returns json encoded string containing true and success message if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$user = array(
‘username’ => ‘myuser’,
‘passwd’ =>’test’,
’email’ => ’email@email.com’,
);
$arguments = array(‘usr_id’ => 5, ‘user’=> $user);
$result = broadcast_api(‘User_Update’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

iii) User_Password_Update – top
This function update password and pincode in ICTBroadcast for given user.
Input Parameters
usr_id: A usr_id of the user whose information is to be updated.
newpass: optional, new password for the user.
pincode: optional, new pin code for the user.
Output
Returns json encoded string containing true and success message if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘usr_id’ => 5, ‘newpass’ => ‘newpass’, ‘pincode’ => ‘2342’);
$result = broadcast_api(‘User_Password_Update’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

iv) User_List – top
This function list all the users in ICTBroadcast.
Input Parameters
no input paramenter
Output
Returns json encoded string containing true if successful and an array of users (each user will also be an array). In case of any failure, it will return false. User object / array will consist of following fields. usr_id, username, first_name, last_name, email, phone, company, address, credit, channel
Sample Code

<?php
$arguments = array();
$result = broadcast_api(‘User_List’, $arguments);
$msg = $result[1];
print_r($msg);
?>

v) User_Get – top
This function searches user from ICTBroadcast users.
Input Parameters
search: Search parameter on which you want to search e.g. username, first_name, last_name, email, phone, address or usr_id etc.
value: Search value that correspond to the parameter that you specified in ‘search parameter’.
Output
Returns json encoded string containing true and success message if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘search’=> ’email’, ‘value’=> ’email@email.com’);
$result = broadcast_api(‘User_Get’, $arguments);
if($result[0] == true) {
$result = $result[1];
print_r($result);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

vi) User_Delete – top
This function removes a user from ICTBroadcast.
Input Parameters
usr_id: ID of the user that is to be removed
Output
Returns json encoded string containing true if successful. In case of any failure, it will return false.
Sample Code

<?php
$usr_id = 5;
$arguments = array(‘usr_id’=> $usr_id);
$result = broadcast_api(‘User_Delete’, $arguments);
$msg = $result[1];
print_r($msg);
?>

vii) User_Login – top
This function logs-in a user through REST API. This is useful for single sign-on feature.
Input Parameters
usr_id: ID of the user
Output
Returns json encoded string containing true and session_id if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘usr_id’=> 5);
$result = broadcast_api(‘User_Logout’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

viii) User_Logout – top
This function logs-out a user through REST API. Calling this function will destroy users session on the server.
Input Parameters
usr_id: ID of the user
Output
Returns json encoded string containing true if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(‘usr_id’=> 5);
$result = broadcast_api(‘User_Logout’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ix) User_Extension_Create – top
This function creates an extension and assigns it to the user whose Id is provided in function call.
Input Parameters
usr_id: ID of the user to which the extension will be assigned
extension: An array containing the extension data. For example, name, secret, dialstring etc.
Output
Returns json encoded string containing extension_id and secret if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$extension = array(
‘name’ => ‘12345’,
‘secret’ =>’test’,
);
$arguments = array(‘usr_id’=> 5, ‘extension’=> $extension);
$result = broadcast_api(‘User_Extension_Create’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

x) User_Role_List – top
This function list all the roles defined in ICTBroadcast.
Input Parameters
no input paramenter
Output
Returns json encoded string containing true if successful and an array of roles. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array();
$result = broadcast_api(‘User_Role_List’, $arguments);
$msg = $result[1];
print_r($msg);
?>

xi) User_Credit_Get – top
This function returns credit of ICTBroadcast user whose ID is provided.
Input Parameters
usr_id: ID of the user whose credit is required.
Output
Returns json encoded string containing true and success message if successful. In case of failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(
‘usr_id’ => 2,
);
$result = broadcast_api(‘User_Credit_Get’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xii) User_Payment_Create – top
This function creates a payment from a user whose id is provided. This payment amount will credited into that user’s account.
Input Parameters
usr_id: ID of the user who paid the amount
value: Paid amount that will be added to user’s account
type: Payment type. One of the following 4 values. cash, cheque, online, other.
description: Any textual description associated with this payment.
paid_date: Optional, Date payment made on. example 2014-06-05, if missing current date will be used
Output
Returns json encoded string containing true and success message if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(
‘usr_id’ => 5,
‘value’ => 500,
‘type’ => ‘cash’,
‘description’ => ‘Paid cash amount’);
$result = broadcast_api(‘User_Payment_Create’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xiii) User_Payment_List – top
This function list of all the payments made by a user.
Input Parameters
usr_id: Optional. id of the user.
Output
Returns json encoded string containing true and list of payments if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘usr_id’=> $usr_id);
$result = broadcast_api(‘User_Payment_List’, $arguments);
if($result[0] == true) {
$paymentList = $result[1];
foreach ($paymentList as $payment) {
print_r($payment);
}
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xiv) User_Permission_Create – top
This function assigns a permission to the user whose ID is provided.
Input Parameters
usr_id: ID of the user
permission: Name of the permission that is to be assigned
Output
Returns json encoded string containing true and success message if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(
‘usr_id’ => 5,
‘permission’ => ‘ivr_edit’,
);
$result = broadcast_api(‘User_Permission_Create’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xv) User_Permission_Delete – top
This function remove a permission of the user whose ID is provided.
Input Parameters
usr_id: ID of the user
permission: Name of the permission that is to be removed
Output
Returns json encoded string containing true and success message if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(
‘usr_id’ => 5,
‘permission’ => ‘ivr_edit’,
);
$result = broadcast_api(‘User_Permission_Delete’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xvi) User_Resource_Create – top
This function assigns a resource to the user whose ID is provided.
Input Parameters
usr_id: ID of the user
resource: Name of the resource that is to be assigned
Output
Returns json encoded string containing true and success message if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(
‘usr_id’ => 5,
‘resource’ => ‘weekday’,
‘data’ => ‘2,3,4,5,6’, // Mon-to-Fri
);
$result = broadcast_api(‘User_Resource_Create’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

xvii) User_Resource_Delete – top
This function remove a resource of the user whose ID is provided.
Input Parameters
usr_id: ID of the user
resource: Name of the resource that is to be removed
Output
Returns json encoded string containing true and success message if successful. In case of any failure, it will return false with a failure message.
Sample Code

<?php
$arguments = array(
‘usr_id’ => 5,
‘resource’ => ‘weekday’,
);
$result = broadcast_api(‘User_Resource_Delete’, $arguments);
if($result[0] == true) {
print_r($result[1]);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

h) DID – top
Following are a set of REST APIs that are DID management specific. These APIs allows to create did, delete did, update dids.
i. DID_Create
ii. DID_Delete
iii.DID_Update
iv. DID_List

i) DID_Create – top
This function creates a new DID.
Input Parameters
did: An array containing the did data. For example, name (DID number), description etc.
Output
Returns json encoded string containing did_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$did = array(
‘name’ => ‘12345678’,
‘description’ => ‘test did’
);
$arguments = array(‘did’=>$did);
$result = broadcast_api(‘DID_Create’, $arguments);
if($result[0] == true) {
$did_id = $result[1];
print_r($did_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) DID_Delete – top
This function removes a did
Input Parameters
did_id: ID of the did that is to be removed
Output
Returns json encoded string containing true if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘did_id’=> $did_id);
$result = broadcast_api(‘DID_Delete’, $arguments);
$msg = $result[1];
print_r($msg);
?>

iii) DID_List – top
This function lists all the dids as per given search pattern.
Input Parameters
search: An array containing search fields and values.
Output
Returns json encoded string containing true and list of dids if successful. In case of any failure, it will return false.
Sample Code

<?php
$search = array(‘name’ => ‘4345’, ‘description’ => ‘test’);
$arguments = array(‘search’=> $search);
$result = broadcast_api(‘DID_List’, $arguments);
if($result[0] == true) {
$did_list = $result[1];
foreach ($did_list as $did) {
print_r($did);
}
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

i) AccessNumber – top
Following are a set of REST APIs that are AccessNumber management specific. These APIs allows to create accessnumber, delete accessnumber, update accessnumbers.
i. AccessNumber_Create
ii. AccessNumber_Delete
iii.AccessNumber_Update
iv. AccessNumber_List

i) AccessNumber_Create – top
This function creates a new AccessNumber.
Input Parameters
accessnumber: An array containing the accessnumber data. For example, name (AccessNumber number), description etc.
Output
Returns json encoded string containing accessnumber_id if successful. In case of any failure, it will return false.
Sample Code

<?php
$accessnumber = array(
‘name’ => ‘12345678’,
‘description’ => ‘test accessnumber’
);
$arguments = array(‘accessnumber’=>$accessnumber);
$result = broadcast_api(‘AccessNumber_Create’, $arguments);
if($result[0] == true) {
$accessnumber_id = $result[1];
print_r($accessnumber_id);
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ii) AccessNumber_Delete – top
This function removes a accessnumber
Input Parameters
accessnumber_id: ID of the accessnumber that is to be removed
Output
Returns json encoded string containing true if successful. In case of any failure, it will return false.
Sample Code

<?php
$arguments = array(‘accessnumber_id’=> $accessnumber_id);
$result = broadcast_api(‘AccessNumber_Delete’, $arguments);
$msg = $result[1];
print_r($msg);
?>

iii) AccessNumber_List – top
This function lists all the accessnumbers as per given search pattern.
Input Parameters
search: An array containing search fields and values.
Output
Returns json encoded string containing true and list of accessnumbers if successful. In case of any failure, it will return false.
Sample Code

<?php
$search = array(‘name’ => ‘4345’, ‘description’ => ‘test’);
$arguments = array(‘search’=> $search);
$result = broadcast_api(‘AccessNumber_List’, $arguments);
if($result[0] == true) {
$accessnumber_list = $result[1];
foreach ($accessnumber_list as $accessnumber) {
print_r($accessnumber);
}
} else {
$errmsg = $result[1];
print_r($errmsg);
}
?>

ICTBroadcast Team
Go To Table of Contents

REST-based API to integrate ICTBroadcast with third party application”