Overview
To configure alerts you will need a Remote API Key, which is not the same as the API Key used to send CDR data to Humbug. The Remote API Key is used for:
  • Adding / Configuring Alerts
  • Adding / Removing sub-API keys to your account
  • General Account Configuration
To obtain a Remote API Key for your account, visit the Settings->Remote API Keys section in the analytics interface.
Remotely add and configure alerts to your account
URL for POST Request: http://analytics.humbuglabs.org/index.php/remote_api/api_remote_add_alert/
Parameter
key
salt
apikey_ident
alert_id
config
2
Description
(string, required) – Your remote API Key, MD5 encrypted together with the salt parameter.
(string, required) – A random string (i.e: timestamp)
(string, required) – The API Key to add the alert to. Alternativly you may use 0 to apply the alert to all your associated API Keys collectivly, or -1 to add the alert for each of your API keys individually.
(int, required) – The ID of the alert to add. See the reference table below.
(JSON string, required) – JSON formatted alert configuration
Sample API Creation POST Request:
key=asoiufb9av8h9ahaq9vh98ahvaspdfiouaba8sy7f&salt=1981938447&apikey_ident=asdf08a7gf0asd8f7ga82f8gag98h&alert_id=18&config={"daily_cost":"120","email":"1","sms":"1"}
Response: (JSON Formatted)
You will receive a JSON response providing you with the status of the request, for example:

{"result":true,"msg":"OK"}
ALERT
ID
Sample Configuration
Blacklist
1
Remote Management Coming Soon
Blacklist Country
2
Remote Management Coming Soon
Unidentified Context
3
{"email":"1","sms":"0"}
Config Reload
4
{"email":"1","sms":"0"}
Blacklist Range
5
Remote Management Coming Soon
Premium Number
6
{"email":"1","sms":"0"}
Timestamp
8
{"email":"1","sms":"0"}
Alarm
9
{"email":"1","sms":"0"}
Timerange
10
{"from_mo_hour":"08","from_mo_min":"00","to_mo_hour":"19","to_mo_min":"00", "from_tu_hour":"08","from_tu_min":"00","to_tu_hour":"19","to_tu_min":"00", "from_we_hour":"08","from_we_min":"00","to_we_hour":"19","to_we_min":"00", "from_th_hour":"08","from_th_min":"00","to_th_hour":"19","to_th_min":"00", "from_fr_hour":"08","from_fr_min":"00","to_fr_hour":"17","to_fr_min":"30", "from_sa_hour":"00","from_sa_min":"00","to_sa_hour":"00","to_sa_min":"00", "sa":"on","from_su_hour":"00","from_su_min":"00","to_su_hour":"00", "to_su_min":"00","su":"on","email":"1"}
Blacklist Community
11
{"email":"1","sms":"0"}
Collector Shutdown
12
{"email":"1","sms":"0"}
Cdr Duration
13
{"cdr_duration":"6000","cdr_type":"all","email":"1","sms":"0"}
Cdr Cost
14
{"cdr_cost":"10","cdr_type":"all","email":"1","sms":"0"}
Cdr Cost Per Min
15
{"cost_per_min":"1","cdr_type":"all","email":"1","sms":"0"}
Threshold Cost Hourly
16
{"hourly_cost":"3","email":"1"}
Threshold Hourly
47
{"volume_threshold":"120","duration_threshold":"400","cost_threshold":"40","email":"1","sms":"0"}
Threshold Weekly
48
{"volume_threshold":"120","duration_threshold":"400","cost_threshold":"40","email":"1","sms":"0"}
Threshold Monthly
49
{"volume_threshold":"120","duration_threshold":"400","cost_threshold":"40","email":"1","sms":"0"}
Threshold Country Hourly
30
Remote Management Coming Soon
Threshold Country Daily
31
Remote Management Coming Soon
Threshold Long Distance Hourly
32
{"local_country":"64","local_countryname":"Israel","volume_threshold":"5", "duration_threshold":"2","cost_threshold":"2","minimum_asr":"1","minimum_calls":""}
Threshold Long Distance Daily
33
{"local_country":"64","local_countryname":"Israel","volume_threshold":"5", "duration_threshold":"2","cost_threshold":"2","minimum_asr":"1","minimum_calls":""}
Threshold Long Distance Monthly
34
{"local_country":"64","local_countryname":"Israel","volume_threshold":"5", "duration_threshold":"2","cost_threshold":"2","minimum_asr":"1","minimum_calls":""}
Programatically remove alerts from your account.
URL for POST Request: http://analytics.humbuglabs.org/index.php/remote_api/remote_del_alert/
Parameter
key
salt
apikey_ident
alert_id
Description
(string, required) – Your remote API Key, MD5 encrypted together with the salt parameter.
(int, required) – A random string
(string, required) – The API Key to remove the alert from. Alternativly you may use 0 to apply the alert to all your associated API Keys collectivly, or -1 to add the alert for each of your API keys individually.
(string, required) – API Key to remove
Sample API Deletion POST Request:
key=asoiufb9av8h9ahaq9vh98ahvaspdfiouaba8sy7f&salt=1981938447&apikey_ident=sd89f7hf0as978fg2s9f8h2as8f7gas0
Response: (JSON Formatted)
You will receive a JSON response:

{"result":true,"msg":"OK"}
Adding Alerts - PHP example
									 function set_humbug_alert() {
									      //the url we are sending data to
										  $url              = 'http://analytics.humbuglabs.org/index.php/remote_api/api_remote_add_alert/';
										
										  // your Remote API Key
										  $remote_apikey    = 'your-remote-apikey';
										  
										  //Encrypt the API Key using a random string (salt)
										  $salt 		 	= time();
										  $remote_apikey 	= md5($remote_apikey.$salt);
										  
										  //The API Key of the gateway/pbx that we want to add an alert to
										  $gateway_apikey	= 'your-pbx-apikey';
										  
										  //The ID of the alert we want to add. 
										  $alert_id   		= 18;
										  
										  //Sample JSON config for this alert. 
										  //maximum daily cost threshold of $100 and emailing alerts set to ON.
										  $config 			= '{"daily_cost":"100","email":"1"}';
										  
										  //in our example we're building an array of the values we need to send
									      $array = array (
												            'key'           => $remote_apikey,
												            'salt'          => $salt,
															'apikey_ident'  => $gateway_apikey,
												            'alert_id'      => $alert_id,
												            'config'        => $config
												         );
										
										  //turn the array into a key=value string for usage with cURL
										  $params    = "";
									      foreach($array as $key => $value) {
									            $params .= $key.'='.$value.'&';
									      }
									      rtrim($params,'&');
										  
										  //send the data
									      $ch = curl_init();
									      curl_setopt($ch,CURLOPT_URL,$url);
									      curl_setopt($ch,CURLOPT_POST,count($array));
									      curl_setopt($ch,CURLOPT_POSTFIELDS,$params);
									      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
									      $result = curl_exec($ch);
									      curl_close($ch);
										  print_r($result);
									}