WEB API: Difference between revisions

From VoIPmonitor.org
Jump to navigation Jump to search
No edit summary
No edit summary
 
(73 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Custom Login =
== Custom Login ==


Custom login allows to implement your own login mechanism. You need to create file scripts/custom_login.php and function custom_login
=== LDAP Example ===


custom login script: /scripts/custom_login.php  
Complete LDAP example available in GUI directory: scripts/ldap_custom_login_example.php.
 
Ensure php-ldap package (or equivalent) is installed on the OS hosting the LDAP script.
 
=== Custom Script ===
 
Custom login enables implementing your own mechanism. Create file: scripts/custom_login.php with function custom_login.
 
Location: <GUI_INSTALL_DIR>/scripts/custom_login.php


  <?php
  <?php
  function custom_login($user, $password) {
  function custom_login($user, $password) {
         debug_log('custom_login');
         debug_log('custom_login');
Line 12: Line 19:
                 'username' => $user,
                 'username' => $user,
                 'is_admin' => false,
                 'is_admin' => false,
                'id' => $userIdUniqueNum, // required numeric unique identifier for each user
// 'id_group' => 1, // you can set user rights with the gui's group id too
                 'enable_sensors' => array(2,3)
                 'enable_sensors' => array(2,3)
         ));
         ));
  }
  }
?>


Returned array parameters:


The array can return those parameters:
*enable_sensors - array(A,B,...) where the number is number of the sensor. If no enable_sensors provided the user will see all sensors CDR.
 
*enable_sensors - array(A,B,...) where the number is number of the sensor. If no enable_sensors provided the user will see all sensors CDR.  
*username
*username
*name
*name
*password
*secret
*ip
*number
*domain
*id_group
*id_group
*note
*group_name
*can_listen
*group_blocked
*no_rtp
*can_cdr
*can_write_cdr
*can_play_audio
*can_download_audio
*can_listen_active_call
*can_show_fax
*can_show_fax
*can_pcap
*can_pcap
Line 35: Line 45:
*can_messages
*can_messages
*can_view_content_message
*can_view_content_message
*can_view_message_url
*is_admin
*is_admin
*can_write_cdr
*no_rtp
*simple_cdr
*simple_cdr
*dynamic_cdr_title
*hide_cdr_groups
*hide_cdr_groups
*can_graphs
*can_graphs
Line 44: Line 54:
*can_activecalls
*can_activecalls
*can_register
*can_register
*can_sip_msg
*can_livesniffer
*can_livesniffer
*can_capture_rules
*can_capture_rules
*crules_remove_expire_time
*can_audit
*can_audit
*can_alerts_edit
*can_alerts_edit
Line 51: Line 63:
*can_reports_edit
*can_reports_edit
*can_reports_show_sent
*can_reports_show_sent
*can_cdr_share
*can_cdr_share_local_public
*can_cdr_share_local_private
*can_cdr_share_voipmonitor_org
*can_cdr_share_voipmonitor_org
*hide_license_information
*hide_license_information
Line 60: Line 73:
*show_only_connected_calls
*show_only_connected_calls
*can_dashboard
*can_dashboard
*dashboard_read_only
*can_report_functions
*can_report_functions
*hide_change_password
*hide_user_configuration
*password_expired
*can_svg_paint
*can_3d_rtp_charts
*can_network
*can_edit_codebooks
*can_edit_all_templates
*can_delete_all_templates
*ip
*number
*domain
*vlan
*custom_headers_cdr
*custom_headers_message
*ip_number_domain_or
*note
*email
*email
*blocked
*blocked_reason
*max_bad_login_attempt
*password_expiration_days
*enable_login_ip
*uc_color_theme_shift_h
*uc_color_theme_shift_h
*uc_color_theme_shift_s
*uc_color_theme_shift_s
Line 70: Line 106:
*uc_enable_dns_cdr
*uc_enable_dns_cdr
*uc_enable_dns_message
*uc_enable_dns_message
*uc_enable_flags_cdr_number
*uc_enable_flags_cdr_ip
*uc_enable_flags_message_number
*uc_enable_flags_message_ip
*uc_csv_field_separator
*count_audit_log
*req_2fa
== CDR HTTP API ==
Retrieves CDR rows in JSON, using WEB GUI filters: [[Call_Detail_Record_-_CDR#Filter_Form_button]].
Requires valid session: [[GUI_automate_login]]. Send parameters via POST.
Disable authorization (safe environments): '''GUI > Settings > System Configuration > Disable authorization for API usage'''.
=== CURL Notes ===


= CDR HTTP API =
Use -G and --data-urlencode for special characters (e.g., + in caller).


This method allows to get CDR rows formatted in JSON which you can see in the WEB GUI using the same filter which you can see in the WGB GUI: [[Call_Detail_Record_-_CDR#Filter_Form_button]]
Example:


You need to have valid session [[GUI_automate_login]] and you have to send those parameters via POST request
curl -G -X GET 'http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD' --data-urlencode 'params=[{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414414"},{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"1+1","customHeaders":"Cell-ID-Caller,Cell-ID-Called"}]'


== INPUT ==
=== Input ===


HTTP POST address - php/model/sql.php
HTTP POST address: php/model/sql.php


=== Mandatory parameters ===
==== Mandatory Parameters ====


  task:LISTING module:CDR
  task:LISTING module:CDR


=== suppress_results ===
fdatefrom:DATE or fdateto:DATE is required due to mysql overloading


suppress_results:1
==== Suppress Results ====


will not list CDR but only {"total":"135"}
suppress_results:1


=== Datetime range ===
will not list CDR but only {"total":"135"}
 
==== Datetime Range ====


  fdatefrom:1986-01-09T00:00:00 fdateto:2013-05-28T00:00:00
  fdatefrom:1986-01-09T00:00:00 fdateto:2013-05-28T00:00:00


=== Caller / called numbers ===
==== Caller / Called Numbers ====


  fcaller: caller num
  fcaller: caller num
Line 101: Line 156:
  fcallerd_type: 0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
  fcallerd_type: 0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)


==== Domain ====


=== Domain ===
  fcaller_domain: caller domain fcalled_domain: caller domain
  fcaller_domain: caller domain fcalled_domain: caller domain
  fcallerd_domain_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
  fcallerd_domain_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)


=== Caller id name ===
==== Caller ID Name ====


  fcallername: caller name
  fcallername: caller name
=== SIP caller / called IP ===
 
==== SIP Caller / Called IP ====


  fsipcallerip: caller SIP IP fsipcalledip: called SIP IP
  fsipcallerip: caller SIP IP fsipcalledip: called SIP IP
  fsipcallerdip_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
  fsipcallerdip_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
=== RTP source / destination IP ===


==== RTP Source / Destination IP ====


  fa_saddr: 192.168.0.1
  fa_saddr: 192.168.0.1
Line 120: Line 176:
  fab_saddr_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
  fab_saddr_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)


=== Codecs ===
==== Codecs ====


  fcodec: 4, 12
  fcodec: 4, 12
list of numbers delimited by ','. Here is list of numbers and its codecs
list of numbers delimited by ','. Here is list of numbers and its codecs
define("PAYLOAD_PCMU", 0); define("PAYLOAD_GSM", 3); define("PAYLOAD_G723", 4); define("PAYLOAD_PCMA", 8); define("PAYLOAD_G722", 9); define("PAYLOAD_QCELP", 12); define("PAYLOAD_CN", 13); define("PAYLOAD_G729", 18); define("PAYLOAD_ILBC", 97); define("PAYLOAD_SPEEX", 98); define("PAYLOAD_SILK", 301); define("PAYLOAD_SILK8", 302); define("PAYLOAD_SILK12", 303); define("PAYLOAD_SILK16", 304); define("PAYLOAD_SILK24", 305); define("PAYLOAD_ISAC", 306); define("PAYLOAD_ISAC16", 307); define("PAYLOAD_ISAC32", 308); define("PAYLOAD_T38", 1000);
==== Call Duration ====


define("PAYLOAD_PCMU", 0); define("PAYLOAD_GSM", 3); define("PAYLOAD_G723", 4); define("PAYLOAD_PCMA", 8); define("PAYLOAD_G722", 9); define("PAYLOAD_QCELP", 12); define("PAYLOAD_CN", 13); define("PAYLOAD_G729", 18); define("PAYLOAD_ILBC", 97); define("PAYLOAD_SPEEX", 98); define("PAYLOAD_SILK", 301); define("PAYLOAD_SILK8", 302); define("PAYLOAD_SILK12", 303); define("PAYLOAD_SILK16", 304); define("PAYLOAD_SILK24", 305); define("PAYLOAD_ISAC", 306); define("PAYLOAD_ISAC16", 307); define("PAYLOAD_ISAC32", 308); define("PAYLOAD_T38", 1000);
=== Call duration ===
example: less than 30 and greater than 10 seconds
example: less than 30 and greater than 10 seconds
  fdurationgt: 30 fdurationlt: 10
  fdurationgt: 30 fdurationlt: 10


=== PDD ===
==== PDD ====


example: greater than 10 and less than 30 seconds
example: greater than 10 and less than 30 seconds
  fpddgt: 10 fpddlt: 30
  fpddgt: 10 fpddlt: 30


=== Sip response code ===
==== SIP Response Code ====
 
  fsipresponse: 503
  fsipresponse: 503


=== Interrupted call ===
==== Interrupted Call ====


false or true
false or true
fbye:false


fbye:false
Direction (by trunk)
Direction (by trunk)
false or true
false or true
  ftrunk:
  ftrunk:


Line 153: Line 209:
  fa_ua: caller agent string fb_ua: called agent string
  fa_ua: caller agent string fb_ua: called agent string
  fab_ua_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
  fab_ua_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)
SIP Call-ID header  
 
SIP Call-ID header
  fcallid: string
  fcallid: string


SIP sensor ID (database ID)  
SIP sensor ID (database ID)
  fsensor_id:
  fsensor_id:


 
==== Paging ====
 
=== Paging ===


  page:1 start:0 limit:30
  page:1 start:0 limit:30


=== Ordering ===
==== Ordering ====


  sort:[{"property":"calldate2","direction":"DESC"}]
  sort:[{"property":"calldate2","direction":"DESC"}]


==== Special Ordering ====


=== Special Ordering ===
  orderByLoss: orderByDelay: orderByFixed1: orderByFixed2: orderByAdapt: orderByCallDuration_asc: orderByCallDuration_desc: orderBySrcSIP_IP_asc: orderBySrcSIP_IP_desc: orderByDstSIP_IP_asc: orderByDstSIP_IP_desc: orderBySrcNumber_asc: orderBySrcNumber_desc: orderByDstNumber_asc: orderByDstNumber_desc: orderByCallerName_asc: orderByCallerName_desc: orderByLastSIPrespNum_asc: orderByLastSIPrespNum_desc:
  orderByLoss: orderByDelay: orderByFixed1: orderByFixed2: orderByAdapt: orderByCallDuration_asc: orderByCallDuration_desc: orderBySrcSIP_IP_asc: orderBySrcSIP_IP_desc: orderByDstSIP_IP_asc: orderByDstSIP_IP_desc: orderBySrcNumber_asc: orderBySrcNumber_desc: orderByDstNumber_asc: orderByDstNumber_desc: orderByCallerName_asc: orderByCallerName_desc: orderByLastSIPrespNum_asc: orderByLastSIPrespNum_desc:
=== RTP ===
 
==== RTP ====
 
  frtcp_maxjitter: frtcp_avgjitter: frtcp_maxfr: frtcp_avgfr: fmosf1: fmosf2: fmosadapt: f_d50: f_d70: f_d90: f_d120: f_d150: f_d200: f_d300: floss1: floss2: floss3: floss4: floss5: floss6: floss7: floss8: floss9: floss10: ffilterTemplate:
  frtcp_maxjitter: frtcp_avgjitter: frtcp_maxfr: frtcp_avgfr: fmosf1: fmosf2: fmosadapt: f_d50: f_d70: f_d90: f_d120: f_d150: f_d200: f_d300: floss1: floss2: floss3: floss4: floss5: floss6: floss7: floss8: floss9: floss10: ffilterTemplate:


== OUTPUT ==
=== Output ===
Output is JSON formated array of CDR  
 
JSON formatted array of CDR.
 
==== GUI in Default DocumentRoot ====
 
Example for /var/www/html


  curl '192.168.76.201/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'
  curl -X POST '192.168.76.201/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'
take the SID which you will put to PHPSESSID curl -X POST -k --cookie "PHPSESSID=28a5395da414b1a20e4723e0651c9f0b" "http://192.168.76.201/php/model/sql.php?task=LISTING&module=CDR&fcaller=190"


returns something like this
{"SID":"ahs2ubdhc0ukb262be60v900ko","cookie_name":"PHPSESSID","success":true,"_vm_version":240034,"_debug":false}


{"total":"25","results":[{"lastSIPresponseNum":"200","lastSIPresponse_id":"3","cnt_all":"110011","duration_all":"5388692","acd_all":"49.3737","asr_all":"99.2092","mos_all":"4.36034442","packets_lost_all":"0.15386185","jitter_all":"1.03656707","delay_all":"116.5833","cnt_ok":null,"cnt_err":null,"lastSIPresponse":"200 OK","id":"200 OK"},{"lastSIPresponseNum":"487","lastSIPresponse_id":"27","cnt_all":"535","duration_all":"256","acd_all":"6.2439","asr_all":"7.6636","mos_all":"3.67647059","packets_lost_all":"0.05965854","jitter_all":"1.00000000","delay_all":"0.5042","cnt_ok":null,"cnt_err":null,"lastSIPresponse":"487 Request Terminated","id":"487 Request Terminated"}]}
take the SID which you will put to cookie_name variable


curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/model/sql.php?task=LISTING&module=CDR&fdatefrom=2013-05-08T00:00:00&fcaller=190"


= Share CDR =
==== GUI in Demo Subdirectory ====


Sharing CDR is possible by sending request to php/model/utilities.php with following parameteres. If you want to share SIP+RTP set type2 to "RTP" and if only SIP set type2:null
Example for /var/www/html/demo


== show link local public ==
curl -X POST '192.168.76.201/demo/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'


  task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"self_protected_link","id":[128024514],"emailFields":null}
returns something like this
  {"SID":"ahs2ubdhc0ukb262be60v900ko","cookie_name":"PHPSESSID-demo","success":true,"_vm_version":240034,"_debug":false}


take the SID which you will put to cookie_name variable


== show link local private ==
curl -X POST -k --cookie "PHPSESSID-demo=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/demo/php/model/sql.php?task=LISTING&module=CDR&fdatefrom=2013-05-08T00:00:00&fcaller=190"


==== Example Output for LISTING Task ====


task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"self_login_link","id":[128024514],"emailFields":null}
See attached link: [[output of the API LISTING task]]


== Share CDR ==


Share CDR via request to php/model/utilities.php. For SIP+RTP, set type2 to "rtp"; for SIP only, type2:null.


== show link share.voipmonitor.org ==
=== Show Link Local Public ===


task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"self_protected_link","id":[128024514],"emailFields":null}


task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"share_link","id":[128024590],"emailFields":null}
=== Show Link Local Private ===


task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"self_login_link","id":[128024514],"emailFields":null}


=== Show Link share.voipmonitor.org ===


= get PCAP file =  
task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"share_link","id":[128024590],"emailFields":null}


To get pcap file send GET or POST request with id of the CDR:  
== Get PCAP File ==
 
GET or POST request with CDR ID:


  http://voipmonitor/php/pcap.php?id=203800251
  http://voipmonitor/php/pcap.php?id=203800251


optinaly RTP can be filtered out by adding parameter disable_rtp=1
Optionally filter out RTP: disable_rtp=1


= Search CDR by URL =
== Search CDR by URL ==


If you would like to build URL which will show CDR in web browser matching filter you can use cdr_filter parameter for admin.php
Build URL for CDR display in browser:


  http://localhost/admin.php?cdr_filter={fcallid:"uDR8mtloKFa1F8625VL2OXSFp.RuG73v"}
  http://localhost/admin.php?cdr_filter={fcallid:"uDR8mtloKFa1F8625VL2OXSFp.RuG73v"}


cdr_filter takes the same arguments like in section [[WEB_API#CDR_HTTP_API]]
cdr_filter uses same arguments as [[WEB_API#CDR_HTTP_API]]
 
== HTTP API 2 ==
 
Preferred API for audio files by search criteria. Requests via HTTP POST or GET.


= HTTP API 2 =  
=== Rate Limit ===


This API was created for getting audio files based on various search criteria. Requests are over HTTP POST or GET
Enable in '''GUI > Settings > System Configuration > API maximal concurrent connections'''. Limit per user.


== getVoipCalls ==
=== getVoipCalls ===


=== Input data ===
==== Input Data ====


*startTime - all calls which started >= startTime
*startTime - all calls which started >= startTime
Line 239: Line 315:
*caller - caller number
*caller - caller number
*called - called number
*called - called number
*callId - Call-ID
*id_sensor - sensor's number
*msisdn - when you enter caller and called then cond is 'caller = 9999999 and called = 9999998'. With msisdn the cond is 'caller = 9999997 or called = 9999997'
*cdrId - ID number in db
*onlyConnected - 0 or 1 - get only connected calls or all calls (ringing)
*onlyConnected - 0 or 1 - get only connected calls or all calls (ringing)
 
*[custom header name]: [custom header value], seach cdrs by this custom header value
*customHeaders - the names of the returned custom header's values
  task: getVoipCalls,
  task: getVoipCalls,
  user: USER,
  user: USER,
  password: PASSWORD,
  password: PASSWORD,
auditReason: reason text for audit log (not required),
  params: {
  params: {
   startTime: YYYY-MM-DD HH:II:SS,
   startTime: YYYY-MM-DD HH:II:SS,
Line 249: Line 331:
   callEnd: YYYY-MM-DD HH:II:SS,
   callEnd: YYYY-MM-DD HH:II:SS,
   caller: 9999999,
   caller: 9999999,
   called: 9999999
   called: 9999999,
  callId: 'XXXXXXXXXXXXXXXXXXXXXX',
  id_sensor: 5,
  msisdn: 9999997,
  cdrId: 99999,
  onlyConnected: 0,
  [custom header name]: [custom header value],
  customHeaders: "Cell-ID-Caller,Cell-ID-Called"
  }
  }


=== Examples ===
==== Examples ====
==== HTTP POST Simple parameter ====
 
  echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": {"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251414"}}' | php api.php
===== HTTP POST Simple Parameter =====
==== HTTP POST Array parameter ====
 
  echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": [{"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251414"},{"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251415"}]}' | php api.php       
  echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": {"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251414414","customHeaders": "Cell-ID-Caller,Cell-ID-Called"}}' | php php/api.php
==== HTTP GET Simple parameter ====
  echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": {"startTime": "2023-01-01", "endTime": "2023-08-01", "callId": "a90eb404-4c12-363b-4812-56622343fbdf"}}' | php php/api.php
http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD&params={"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414"}
==== HTTP GET Array parameter ====
http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD&params=[{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414"},{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251415"}]


== getVoiceRecording by Cdr ID ==
===== HTTP POST Array Parameter =====


=== input data ===
  echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": [{"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251414"},{"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251415", "customHeaders": "Cell-ID-Caller,Cell-ID-Called"}]}' | php php/api.php
  task: getVoiceRecording,  
user: USER,
password: PASSWORD,
params: { cdrId: 999999 }
}


optional parameters - zip, ogg (true|false)
===== HTTP GET Simple Parameter =====


=== Examples ====
http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD&params={"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414","customHeaders":"Cell-ID-Caller,Cell-ID-Called"}
=== HTTP POST ====
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"cdrId": "4919"}}' | php api.php


===== HTTP GET Array Parameter =====


==== HTTP GET ====
  http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD&params=[{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414"},{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251415","customHeaders":"Cell-ID-Caller,Cell-ID-Called"}]
  http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"cdrId":4919}


== getVoiceRecording by Call ID ==
=== getVoiceRecording ===


=== input data ===
==== Input Data ====
task: getVoiceRecording,
user: USER,
password: PASSWORD,
params: {  callId: 'XXXXXXXXXXXXXXXXXXXXXX' }}


  task: getVoiceRecording,
  task: getVoiceRecording,
  user: USER,
  user: USER,
  password: PASSWORD,
  password: PASSWORD,
  params: {  customHeader: 'name of the column in cdr_next table', customHeaderValue: 'your value' }}
auditReason: reason text for audit log (not required),
  params: {
      cdrId: 999999
      callId: 'XXXXXXXXXXXXXXXXXXXXXX',
      "CustomHeaderName": "CustomHeaderValue,
      calldate: '2015-03-01' //default value is current date, not used when cdrId set
}
or
  params: { customHeader: 'name of the column in cdr_next table', customHeaderValue: 'your value', calldate: '2015-03-01' } //not recommended


=== examples ===
===== Optional Parameters for Params =====
==== HTTP POST ====
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"callId": "XXXXXXXXXXXXXXXXXXXXXX"}}' | php api.php
 
==== HTTP GET ====
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX"}
 
= direct links =
 
Active calls - index.php?activecalls=1&hidegrid=1&hidemenu=1


                  zip, ogg, : (true|false)
    saveaudio_afterconnect : ("yes"|"no")


==== Examples ====


===== HTTP POST =====


echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"cdrId": "4919"}}' | php api.php
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"cdrId": [6,7],"saveaudio_afterconnect":"yes"}}' | php api.php > /tmp/m6_m7.wav.zip
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"callId": "XXXXXXXXXXXXXXXXXXXXXX"}}' | php api.php
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"Cust_header": "CustValue"}}' | php api.php


===== HTTP GET =====


http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"cdrId":4919}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"cdrId":4919,"saveaudio_afterconnect":"yes"}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX"}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX","cidInterval":10}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX","cidInterval":10,"saveaudio_afterconnect":"yes"}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"Cust_header":"CustValue"}


=== listActiveCalls ===


==== Input Data ====


task: listActiveCalls,
user: USER,
password: PASSWORD,
params: {
    sensorId: 'sensor number',
    callId: 'callId'
}
sensorId and callId are optional.


==== Examples ====


===== HTTP POST =====


echo '{"task": "listActiveCalls", "user": "USER", "password": "PASSWORD", "params": {"sensorId": "1"}}' | php api.php


===== HTTP GET =====


http://localhost/php/api.php?task=listActiveCalls&user=USER&password=PASSWORD&params={"sensorId":"1"}


=== handleActiveCall ===


Start/stop RTP recording. Pausing saves empty RTP frames to PCAP; affects 'Listening to Active call' (no audio from paused calls).


==== Input Data ====


task: handleActiveCall,
user: USER,
password: PASSWORD,
auditReason: reason text for audit log (not required),
params: {
  sensorId: 'sensor number',
  command: 'command (can be only pausecall/unpausecall now)',
  callRef: 'call reference'
}


==== Examples ====


===== HTTP POST =====


echo '{"task": "handleActiveCall", "user": "USER", "password": "PASSWORD", "params": {"sensorId": "1","command":"pausecall","callRef":"0x7f0e4c3c2680"}}' | php api.php


===== HTTP GET =====


http://localhost/php/api.php?task=handleActiveCall&user=USER&password=PASSWORD&params={"sensorId":"1","command":"pausecall","callRef":"0x7f0e4c3c2680"}


=== reportSummary ===


Generates report like image (supports all brown-highlighted subtypes): [[File:report_summary.png]]


==== Input Data ====


task: reportSummary,
user: USER,
password: PASSWORD,
params: {
    report_name: name / description of report (only CDR reports allowed),
    datetime_from: datetime from
    datetime_to: datetime to,
    json: true / false
}


==== Examples ====


===== HTTP POST =====


echo '{"task": "reportSummary", "user": "USER", "password": "PASSWORD", "params": {"report_name": "test summary", "datetime_from": "2017-12-20", "datetime_to": "2017-12-20"}}' | php api.php


===== HTTP GET =====


http://localhost/php/api.php?task=reportSummary&user=USER&password=PASSWORD&params={"report_name":"test summary","datetime_from":"2017-12-20","datetime_to":"2017-12-20"}


=== getShareURL ===


Parameters like getVoiceRecording. Returns public link for LEGs by CID. If 'sip_history' true, only SIP history (RTP ignored).


Options: 'anonIps' anonymizes IPs/domains; 'validDays' limits validity.


==== Examples ====


===== HTTP GET (with RTP) =====


http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60,"rtp":true,"anonIps":true,"validDays":15}
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","rtp":true}


===== HTTP GET (only SIP) =====


http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60}
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225"}


===== HTTP GET (SIP History) =====


http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60, "sip_history": true}
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","sip_history": true}


=== getPCAP ===


Parameters like getVoiceRecording. Returns PCAP (merged legs if multiple in interval). Zip auto if multiple.


==== Examples ====


===== HTTP GET (with RTP) =====


http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"cdrId":"76"}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225"}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60,"cidMerge":true}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60,"cidMerge":true,"zip":true}


=== listCdrIds ===


Returns 'size' CDR records with basic info, starting from 'offset' ID.


==== Input Data ====


task: listCdrIds,
user: USER,
password: PASSWORD,
flags: number, //not required, bitfield format: 0x01 .. simpleOutput, 0x02 .. date in ISO8601 format
params: {
      offset: starting cdr id,
      size: number of cdr records to return
}}


==== Example ====


echo '{"task": "listCdrIds", "user": "USER", "password": "PASSWORD", "params": {"offset":"offset_num","size":"number of cdr records"}}' | php api.php


==== Request ====


task: listCdrIds,
user: USER,
password: PASSWORD,
flags: number, //not required, bitfield format: 0x01 .. simpleOutput, 0x02 .. date in ISO8601 format
params: json_encode: {
          offset: starting cdr id,
          size: number of cdr records to return
}


==== Example ====


http://localhost/php/api.php?task=listCdrIds&user=USER&password=PASSWORD&params={"offset":"offset_num","size":"number_of_cdr_records"}


=== getAudioGraph ===


==== Input Data ====


task: getAudioGraph,
user: USER,
password: PASSWORD,
params: {
    cdrId : number (CDR.id),
    type : S/P/ALL ( Spectrogram / Peaks=Waveform / ALL=including both types and both sides )
    side : L/R ( Left / Right )
    height: px
generating: 1 / 0 ( optional param, default 0, tells if audiograph data can be generated from packets in a spooldir. This parameter is needed if you don't use 'save_audiograph = yes' in the sensor config. If generating is 0 then the api call is looking only for created audiographs.)
}


==== Output ====


Depends on 'type' (zip if "type":"ALL"):


PNG image
zip file


==== Example ====


http://192.168.88.46/voipmonitor-git/gui/php/api.php?task=getAudioGraph&user=USER&password=PASSWORD&params={"cdrId":191,"type":"S","side":"R","height":"100"}


== Direct Links ==


Active calls: index.php?activecalls=1&hidegrid=1&hidemenu=1


== SIP History ==


Retrieves SIP history in various forms.


=== Parameters ===


action: action., currently brief_data, brief, getMSC actions. required
id: cdr id of the call, required
dns_lookup: 0|1 ... make dns lookup
ip_not_allowed: exclude this ips from the output (possibility to hide some internal information)


=== Example of Usage ===


# first get auth session
curl -X POST '192.168.76.201/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'
{"SID":"ahs2ubdhc0ukb262be60v900ko","cookie_name":"PHPSESSID","success":true,"_vm_version":240034,"_debug":false}


* 'brief_data' action get SIP history data in JSON format
curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/pcap2text.php?action=brief_data&id=677&dns_lookup=0&ip_not_allowed=10.1.1.1,10.2.2.0/24
{"results":[{"num":"1","time":0,"src":"80.92.240.130","dst":"185.71.40.210","srcip":"80.92.240.130","dstip":"185.71.40.210","srcport":"5060","dstport":"5060","packet_len":"1046","direction":"-->","protocol":"SIP\/SDP","spec_type":null,"msg":"INVITE sip:2260@10.133.67.250:5060 len:1046","type":"request"},{"num":"2","time":0.054963111877441406,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"437","direction":"-->","protocol":"SIP","spec_type":null,"msg":"100 Trying len:437","type":"response"},{"num":"3","time":0.9610240459442139,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"588","direction":"-->","protocol":"SIP","spec_type":null,"msg":"180 Ringing len:588","type":"response"},{"num":"4","time":28.761795043945312,"src":"80.92.240.130","dst":"185.71.40.210","srcip":"80.92.240.130","dstip":"185.71.40.210","srcport":"5060","dstport":"5060","packet_len":"412","direction":"-->","protocol":"SIP","spec_type":null,"msg":"CANCEL sip:2260@10.133.67.250:5060 len:412","type":"request"},{"num":"5","time":28.795578002929688,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"433","direction":"-->","protocol":"SIP","spec_type":null,"msg":"200 OK len:433","type":"response"},{"num":"6","time":28.800518035888672,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"448","direction":"-->","protocol":"SIP","spec_type":null,"msg":"487 Request Cancelled len:448","type":"response"},{"num":"7","time":28.811052083969116,"src":"80.92.240.130","dst":"185.71.40.210","srcip":"80.92.240.130","dstip":"185.71.40.210","srcport":"5060","dstport":"5060","packet_len":"466","direction":"-->","protocol":"SIP","spec_type":null,"msg":"ACK sip:226@10.133.67.250:5060 len:466","type":"request"}],"total":7,"errors":{},"success":true,"_debug":false}


* 'brief' action get SIP history in simple HTML format (as table tag)
curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/pcap2text.php?action=brief&id=677&dns_lookup=0&ip_not_allowed=10.1.1.1,10.2.2.0/24


* 'genMSC' action get SIP history as diagram in HTML format
curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/pcap2text.php?action=getMSC&id=677&dns_lookup=0&ip_not_allowed=10.1.1.1,10.2.2.0/24


== Check License ==


* Basic test for license (covers ionCube issues):


'http://localhost:88/php/apilicensecheck.php?task=licenseCheck'
{"status":1,"message":"license file key.php expired. Current date: 2021-02-23 Expiration date: 2021-02-16"}
'http://localhost:88/php/apilicensecheck.php?task=licenseCheck'
{"status":0,"message":"License OK."}


* Test concurrent calls limit (requires functional ionCube):


'http://localhost:88/php/apilicensecheck.php?task=licenseCallsLimitCheck'


Examples:


{"status":1,"message":"You have exceeded the license limit for concurrent calls and the system has been locked. Contact support."}
{"status":1,"message":"You have exceeded the license limit for concurrent calls. The system will be locked in 14 days. Contact support."}
{"status":0,"message":"Limit violation for 2nd consecutive day."}


=== AI Summary for RAG ===


'''Summary:''' This article covers VoIPmonitor's custom login (LDAP/script examples, parameters), CDR HTTP API (inputs/outputs, examples), sharing CDRs, getting PCAPs, URL searches, HTTP API 2 (getVoipCalls, recordings, active calls, reports, shares, PCAPs, CDR lists, audio graphs), direct links, SIP history retrieval, and license checks.


'''Keywords:''' custom login, LDAP, CDR API, HTTP API, getVoipCalls, getVoiceRecording, active calls, reportSummary, getShareURL, getPCAP, SIP history, license check


.
'''Key Questions:'''
* How to implement custom login in VoIPmonitor?
* What parameters does the CDR HTTP API support?
* How to share CDRs via API?
* What is HTTP API 2 and its methods?
* How to retrieve SIP history?
* How to check VoIPmonitor license via API?

Latest revision as of 14:31, 10 November 2025

Custom Login

LDAP Example

Complete LDAP example available in GUI directory: scripts/ldap_custom_login_example.php.

Ensure php-ldap package (or equivalent) is installed on the OS hosting the LDAP script.

Custom Script

Custom login enables implementing your own mechanism. Create file: scripts/custom_login.php with function custom_login.

Location: <GUI_INSTALL_DIR>/scripts/custom_login.php

<?php
function custom_login($user, $password) {
        debug_log('custom_login');
        return(array(
                'username' => $user,
                'is_admin' => false,
                'id' => $userIdUniqueNum, // required numeric unique identifier for each user
// 'id_group' => 1, // you can set user rights with the gui's group id too
                'enable_sensors' => array(2,3)
        ));
}
?>

Returned array parameters:

  • enable_sensors - array(A,B,...) where the number is number of the sensor. If no enable_sensors provided the user will see all sensors CDR.
  • username
  • name
  • secret
  • id_group
  • group_name
  • group_blocked
  • can_cdr
  • can_write_cdr
  • can_play_audio
  • can_download_audio
  • can_listen_active_call
  • can_show_fax
  • can_pcap
  • can_upload_pcap
  • can_messages
  • can_view_content_message
  • can_view_message_url
  • is_admin
  • no_rtp
  • simple_cdr
  • hide_cdr_groups
  • can_graphs
  • can_tracker
  • can_activecalls
  • can_register
  • can_sip_msg
  • can_livesniffer
  • can_capture_rules
  • crules_remove_expire_time
  • can_audit
  • can_alerts_edit
  • can_alerts_show_sent
  • can_reports_edit
  • can_reports_show_sent
  • can_cdr_share_local_public
  • can_cdr_share_local_private
  • can_cdr_share_voipmonitor_org
  • hide_license_information
  • can_ipacc
  • can_mtr
  • can_show_sql_query
  • can_sensors_operations
  • show_only_connected_calls
  • can_dashboard
  • dashboard_read_only
  • can_report_functions
  • hide_change_password
  • hide_user_configuration
  • password_expired
  • can_svg_paint
  • can_3d_rtp_charts
  • can_network
  • can_edit_codebooks
  • can_edit_all_templates
  • can_delete_all_templates
  • ip
  • number
  • domain
  • vlan
  • custom_headers_cdr
  • custom_headers_message
  • ip_number_domain_or
  • note
  • email
  • blocked
  • blocked_reason
  • max_bad_login_attempt
  • password_expiration_days
  • enable_login_ip
  • uc_color_theme_shift_h
  • uc_color_theme_shift_s
  • uc_color_theme_shift_v
  • uc_color_theme_shift
  • uc_font_main_menu
  • uc_disable_confirm_before_unload
  • uc_enable_dns_cdr
  • uc_enable_dns_message
  • uc_enable_flags_cdr_number
  • uc_enable_flags_cdr_ip
  • uc_enable_flags_message_number
  • uc_enable_flags_message_ip
  • uc_csv_field_separator
  • count_audit_log
  • req_2fa

CDR HTTP API

Retrieves CDR rows in JSON, using WEB GUI filters: Call_Detail_Record_-_CDR#Filter_Form_button.

Requires valid session: GUI_automate_login. Send parameters via POST.

Disable authorization (safe environments): GUI > Settings > System Configuration > Disable authorization for API usage.

CURL Notes

Use -G and --data-urlencode for special characters (e.g., + in caller).

Example:

curl -G -X GET 'http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD' --data-urlencode 'params=[{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414414"},{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"1+1","customHeaders":"Cell-ID-Caller,Cell-ID-Called"}]'

Input

HTTP POST address: php/model/sql.php

Mandatory Parameters

task:LISTING module:CDR
fdatefrom:DATE or fdateto:DATE is required due to mysql overloading

Suppress Results

suppress_results:1

will not list CDR but only {"total":"135"}

Datetime Range

fdatefrom:1986-01-09T00:00:00 fdateto:2013-05-28T00:00:00

Caller / Called Numbers

fcaller: caller num
fcalled: called num
fcallerd_type: 0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)

Domain

fcaller_domain: caller domain fcalled_domain: caller domain
fcallerd_domain_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)

Caller ID Name

fcallername: caller name

SIP Caller / Called IP

fsipcallerip: caller SIP IP fsipcalledip: called SIP IP
fsipcallerdip_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)

RTP Source / Destination IP

fa_saddr: 192.168.0.1
fb_saddr: 192.168.0.2
fab_saddr_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)

Codecs

fcodec: 4, 12

list of numbers delimited by ','. Here is list of numbers and its codecs

define("PAYLOAD_PCMU", 0); define("PAYLOAD_GSM", 3); define("PAYLOAD_G723", 4); define("PAYLOAD_PCMA", 8); define("PAYLOAD_G722", 9); define("PAYLOAD_QCELP", 12); define("PAYLOAD_CN", 13); define("PAYLOAD_G729", 18); define("PAYLOAD_ILBC", 97); define("PAYLOAD_SPEEX", 98); define("PAYLOAD_SILK", 301); define("PAYLOAD_SILK8", 302); define("PAYLOAD_SILK12", 303); define("PAYLOAD_SILK16", 304); define("PAYLOAD_SILK24", 305); define("PAYLOAD_ISAC", 306); define("PAYLOAD_ISAC16", 307); define("PAYLOAD_ISAC32", 308); define("PAYLOAD_T38", 1000);

Call Duration

example: less than 30 and greater than 10 seconds

fdurationgt: 30 fdurationlt: 10

PDD

example: greater than 10 and less than 30 seconds

fpddgt: 10 fpddlt: 30

SIP Response Code

fsipresponse: 503

Interrupted Call

false or true

fbye:false

Direction (by trunk) false or true

ftrunk:

SIP user agent

fa_ua: caller agent string fb_ua: called agent string
fab_ua_type:0 (if type is 0 searching is done for fcaller OR fcalled and value is taken from fcaller. If value is 1 searching is done for fcaller AND fcalled)

SIP Call-ID header

fcallid: string

SIP sensor ID (database ID)

fsensor_id:

Paging

page:1 start:0 limit:30

Ordering

sort:[{"property":"calldate2","direction":"DESC"}]

Special Ordering

orderByLoss: orderByDelay: orderByFixed1: orderByFixed2: orderByAdapt: orderByCallDuration_asc: orderByCallDuration_desc: orderBySrcSIP_IP_asc: orderBySrcSIP_IP_desc: orderByDstSIP_IP_asc: orderByDstSIP_IP_desc: orderBySrcNumber_asc: orderBySrcNumber_desc: orderByDstNumber_asc: orderByDstNumber_desc: orderByCallerName_asc: orderByCallerName_desc: orderByLastSIPrespNum_asc: orderByLastSIPrespNum_desc:

RTP

frtcp_maxjitter: frtcp_avgjitter: frtcp_maxfr: frtcp_avgfr: fmosf1: fmosf2: fmosadapt: f_d50: f_d70: f_d90: f_d120: f_d150: f_d200: f_d300: floss1: floss2: floss3: floss4: floss5: floss6: floss7: floss8: floss9: floss10: ffilterTemplate:

Output

JSON formatted array of CDR.

GUI in Default DocumentRoot

Example for /var/www/html

curl -X POST '192.168.76.201/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'

returns something like this

{"SID":"ahs2ubdhc0ukb262be60v900ko","cookie_name":"PHPSESSID","success":true,"_vm_version":240034,"_debug":false}

take the SID which you will put to cookie_name variable

curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/model/sql.php?task=LISTING&module=CDR&fdatefrom=2013-05-08T00:00:00&fcaller=190"

GUI in Demo Subdirectory

Example for /var/www/html/demo

curl -X POST '192.168.76.201/demo/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'

returns something like this

{"SID":"ahs2ubdhc0ukb262be60v900ko","cookie_name":"PHPSESSID-demo","success":true,"_vm_version":240034,"_debug":false}

take the SID which you will put to cookie_name variable

curl -X POST -k --cookie "PHPSESSID-demo=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/demo/php/model/sql.php?task=LISTING&module=CDR&fdatefrom=2013-05-08T00:00:00&fcaller=190"

Example Output for LISTING Task

See attached link: output of the API LISTING task

Share CDR

Share CDR via request to php/model/utilities.php. For SIP+RTP, set type2 to "rtp"; for SIP only, type2:null.

Show Link Local Public

task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"self_protected_link","id":[128024514],"emailFields":null}

Show Link Local Private

task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"self_login_link","id":[128024514],"emailFields":null}

Show Link share.voipmonitor.org

task=shareCdr&params={"type":"share_cdr_show","type2":null,"subType":"share_link","id":[128024590],"emailFields":null}

Get PCAP File

GET or POST request with CDR ID:

http://voipmonitor/php/pcap.php?id=203800251

Optionally filter out RTP: disable_rtp=1

Search CDR by URL

Build URL for CDR display in browser:

http://localhost/admin.php?cdr_filter={fcallid:"uDR8mtloKFa1F8625VL2OXSFp.RuG73v"}

cdr_filter uses same arguments as WEB_API#CDR_HTTP_API

HTTP API 2

Preferred API for audio files by search criteria. Requests via HTTP POST or GET.

Rate Limit

Enable in GUI > Settings > System Configuration > API maximal concurrent connections. Limit per user.

getVoipCalls

Input Data

  • startTime - all calls which started >= startTime
  • startTimeTo - all calls which started <= startTimeTo (not mandatory)
  • callEnd - all calls which ends <= callEnd (not mandatory)
  • caller - caller number
  • called - called number
  • callId - Call-ID
  • id_sensor - sensor's number
  • msisdn - when you enter caller and called then cond is 'caller = 9999999 and called = 9999998'. With msisdn the cond is 'caller = 9999997 or called = 9999997'
  • cdrId - ID number in db
  • onlyConnected - 0 or 1 - get only connected calls or all calls (ringing)
  • [custom header name]: [custom header value], seach cdrs by this custom header value
  • customHeaders - the names of the returned custom header's values
task: getVoipCalls,
user: USER,
password: PASSWORD,
auditReason: reason text for audit log (not required),
params: {
 startTime: YYYY-MM-DD HH:II:SS,
 startTimeTo: YYYY-MM-DD HH:II:SS,
 callEnd: YYYY-MM-DD HH:II:SS,
 caller: 9999999,
 called: 9999999,
 callId: 'XXXXXXXXXXXXXXXXXXXXXX',
 id_sensor: 5,
 msisdn: 9999997,
 cdrId: 99999,
 onlyConnected: 0,
 [custom header name]: [custom header value],
 customHeaders: "Cell-ID-Caller,Cell-ID-Called"
}

Examples

HTTP POST Simple Parameter
echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": {"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251414414","customHeaders": "Cell-ID-Caller,Cell-ID-Called"}}' | php php/api.php
echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": {"startTime": "2023-01-01", "endTime": "2023-08-01", "callId": "a90eb404-4c12-363b-4812-56622343fbdf"}}' | php php/api.php
HTTP POST Array Parameter
echo '{"task": "getVoipCalls", "user": "USER", "password": "PASSWORD", "params": [{"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251414"},{"startTime": "2013-01-01", "endTime": "2013-08-01", "caller": "910251415", "customHeaders": "Cell-ID-Caller,Cell-ID-Called"}]}' | php php/api.php
HTTP GET Simple Parameter
http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD&params={"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414","customHeaders":"Cell-ID-Caller,Cell-ID-Called"}
HTTP GET Array Parameter
http://localhost/php/api.php?task=getVoipCalls&user=USER&password=PASSWORD&params=[{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251414"},{"startTime":"2013-01-01","endTime":"2013-08-01","caller":"910251415","customHeaders":"Cell-ID-Caller,Cell-ID-Called"}]

getVoiceRecording

Input Data

task: getVoiceRecording,
user: USER,
password: PASSWORD,
auditReason: reason text for audit log (not required),
params: {
     cdrId: 999999
     callId: 'XXXXXXXXXXXXXXXXXXXXXX',
     "CustomHeaderName": "CustomHeaderValue,
     calldate: '2015-03-01' //default value is current date, not used when cdrId set
}

or

params: { customHeader: 'name of the column in cdr_next table', customHeaderValue: 'your value', calldate: '2015-03-01' } //not recommended
Optional Parameters for Params
                 zip, ogg, : (true|false)
   saveaudio_afterconnect : ("yes"|"no")

Examples

HTTP POST
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"cdrId": "4919"}}' | php api.php
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"cdrId": [6,7],"saveaudio_afterconnect":"yes"}}' | php api.php > /tmp/m6_m7.wav.zip
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"callId": "XXXXXXXXXXXXXXXXXXXXXX"}}' | php api.php
echo '{"task": "getVoiceRecording", "user": "USER", "password": "PASSWORD", "params": {"Cust_header": "CustValue"}}' | php api.php
HTTP GET
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"cdrId":4919}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"cdrId":4919,"saveaudio_afterconnect":"yes"}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX"}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX","cidInterval":10}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"callId":"XXXXXXXXXXXXXXXXXXXXXX","cidInterval":10,"saveaudio_afterconnect":"yes"}
http://localhost/php/api.php?task=getVoiceRecording&user=USER&password=PASSWORD&params={"Cust_header":"CustValue"}

listActiveCalls

Input Data

task: listActiveCalls,
user: USER,
password: PASSWORD,
params: {
   sensorId: 'sensor number',
   callId: 'callId'
}
sensorId and callId are optional.

Examples

HTTP POST
echo '{"task": "listActiveCalls", "user": "USER", "password": "PASSWORD", "params": {"sensorId": "1"}}' | php api.php
HTTP GET
http://localhost/php/api.php?task=listActiveCalls&user=USER&password=PASSWORD&params={"sensorId":"1"}

handleActiveCall

Start/stop RTP recording. Pausing saves empty RTP frames to PCAP; affects 'Listening to Active call' (no audio from paused calls).

Input Data

task: handleActiveCall,
user: USER,
password: PASSWORD,
auditReason: reason text for audit log (not required),
params: {
  sensorId: 'sensor number',
  command: 'command (can be only pausecall/unpausecall now)',
  callRef: 'call reference'
}

Examples

HTTP POST
echo '{"task": "handleActiveCall", "user": "USER", "password": "PASSWORD", "params": {"sensorId": "1","command":"pausecall","callRef":"0x7f0e4c3c2680"}}' | php api.php
HTTP GET
http://localhost/php/api.php?task=handleActiveCall&user=USER&password=PASSWORD&params={"sensorId":"1","command":"pausecall","callRef":"0x7f0e4c3c2680"}

reportSummary

Generates report like image (supports all brown-highlighted subtypes):

Input Data

task: reportSummary,
user: USER,
password: PASSWORD,
params: {
   report_name: name / description of report (only CDR reports allowed),
   datetime_from: datetime from
   datetime_to: datetime to,
   json: true / false
}

Examples

HTTP POST
echo '{"task": "reportSummary", "user": "USER", "password": "PASSWORD", "params": {"report_name": "test summary", "datetime_from": "2017-12-20", "datetime_to": "2017-12-20"}}' | php api.php
HTTP GET
http://localhost/php/api.php?task=reportSummary&user=USER&password=PASSWORD&params={"report_name":"test summary","datetime_from":"2017-12-20","datetime_to":"2017-12-20"}

getShareURL

Parameters like getVoiceRecording. Returns public link for LEGs by CID. If 'sip_history' true, only SIP history (RTP ignored).

Options: 'anonIps' anonymizes IPs/domains; 'validDays' limits validity.

Examples

HTTP GET (with RTP)
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60,"rtp":true,"anonIps":true,"validDays":15}
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","rtp":true}
HTTP GET (only SIP)
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60}
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225"}
HTTP GET (SIP History)
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60, "sip_history": true}
http://localhost/php/api.php?task=getShareURL&user=USER&password=PASSWORD&params={"callId":"1502262225","sip_history": true}

getPCAP

Parameters like getVoiceRecording. Returns PCAP (merged legs if multiple in interval). Zip auto if multiple.

Examples

HTTP GET (with RTP)
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"cdrId":"76"}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225"}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60,"cidMerge":true}
http://localhost/php/api.php?task=getPCAP&user=USER&password=PASSWORD&params={"callId":"1502262225","cidInterval":60,"cidMerge":true,"zip":true}

listCdrIds

Returns 'size' CDR records with basic info, starting from 'offset' ID.

Input Data

task: listCdrIds,
user: USER,
password: PASSWORD,
flags: number, //not required, bitfield format: 0x01 .. simpleOutput, 0x02 .. date in ISO8601 format
params: {
      offset: starting cdr id,
      size: number of cdr records to return
}}

Example

echo '{"task": "listCdrIds", "user": "USER", "password": "PASSWORD", "params": {"offset":"offset_num","size":"number of cdr records"}}' | php api.php

Request

task: listCdrIds,
user: USER,
password: PASSWORD,
flags: number, //not required, bitfield format: 0x01 .. simpleOutput, 0x02 .. date in ISO8601 format
params: json_encode: {
         offset: starting cdr id,
         size: number of cdr records to return
}

Example

http://localhost/php/api.php?task=listCdrIds&user=USER&password=PASSWORD&params={"offset":"offset_num","size":"number_of_cdr_records"}

getAudioGraph

Input Data

task: getAudioGraph,
user: USER,
password: PASSWORD,
params: {
    cdrId : number (CDR.id),
    type : S/P/ALL ( Spectrogram / Peaks=Waveform / ALL=including both types and both sides )
    side : L/R ( Left / Right )
    height: px
generating: 1 / 0 ( optional param, default 0, tells if audiograph data can be generated from packets in a spooldir. This parameter is needed if you don't use 'save_audiograph = yes' in the sensor config. If generating is 0 then the api call is looking only for created audiographs.)
}

Output

Depends on 'type' (zip if "type":"ALL"):

PNG image
zip file

Example

http://192.168.88.46/voipmonitor-git/gui/php/api.php?task=getAudioGraph&user=USER&password=PASSWORD&params={"cdrId":191,"type":"S","side":"R","height":"100"}

Direct Links

Active calls: index.php?activecalls=1&hidegrid=1&hidemenu=1

SIP History

Retrieves SIP history in various forms.

Parameters

action: action., currently brief_data, brief, getMSC actions. required
id: cdr id of the call, required
dns_lookup: 0|1 ... make dns lookup
ip_not_allowed: exclude this ips from the output (possibility to hide some internal information)

Example of Usage

# first get auth session
curl -X POST '192.168.76.201/php/model/sql.php?module=bypass_login&user=voipmonitor&pass=voipmonitor'
{"SID":"ahs2ubdhc0ukb262be60v900ko","cookie_name":"PHPSESSID","success":true,"_vm_version":240034,"_debug":false}
  • 'brief_data' action get SIP history data in JSON format
curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/pcap2text.php?action=brief_data&id=677&dns_lookup=0&ip_not_allowed=10.1.1.1,10.2.2.0/24
{"results":[{"num":"1","time":0,"src":"80.92.240.130","dst":"185.71.40.210","srcip":"80.92.240.130","dstip":"185.71.40.210","srcport":"5060","dstport":"5060","packet_len":"1046","direction":"-->","protocol":"SIP\/SDP","spec_type":null,"msg":"INVITE sip:2260@10.133.67.250:5060 len:1046","type":"request"},{"num":"2","time":0.054963111877441406,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"437","direction":"-->","protocol":"SIP","spec_type":null,"msg":"100 Trying len:437","type":"response"},{"num":"3","time":0.9610240459442139,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"588","direction":"-->","protocol":"SIP","spec_type":null,"msg":"180 Ringing len:588","type":"response"},{"num":"4","time":28.761795043945312,"src":"80.92.240.130","dst":"185.71.40.210","srcip":"80.92.240.130","dstip":"185.71.40.210","srcport":"5060","dstport":"5060","packet_len":"412","direction":"-->","protocol":"SIP","spec_type":null,"msg":"CANCEL sip:2260@10.133.67.250:5060 len:412","type":"request"},{"num":"5","time":28.795578002929688,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"433","direction":"-->","protocol":"SIP","spec_type":null,"msg":"200 OK len:433","type":"response"},{"num":"6","time":28.800518035888672,"src":"185.71.40.210","dst":"80.92.240.130","srcip":"185.71.40.210","dstip":"80.92.240.130","srcport":"5060","dstport":"5060","packet_len":"448","direction":"-->","protocol":"SIP","spec_type":null,"msg":"487 Request Cancelled len:448","type":"response"},{"num":"7","time":28.811052083969116,"src":"80.92.240.130","dst":"185.71.40.210","srcip":"80.92.240.130","dstip":"185.71.40.210","srcport":"5060","dstport":"5060","packet_len":"466","direction":"-->","protocol":"SIP","spec_type":null,"msg":"ACK sip:226@10.133.67.250:5060 len:466","type":"request"}],"total":7,"errors":{},"success":true,"_debug":false}
  • 'brief' action get SIP history in simple HTML format (as table tag)
curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/pcap2text.php?action=brief&id=677&dns_lookup=0&ip_not_allowed=10.1.1.1,10.2.2.0/24
  • 'genMSC' action get SIP history as diagram in HTML format
curl -X POST -k --cookie "PHPSESSID=ahs2ubdhc0ukb262be60v900ko" "http://192.168.76.201/php/pcap2text.php?action=getMSC&id=677&dns_lookup=0&ip_not_allowed=10.1.1.1,10.2.2.0/24

Check License

  • Basic test for license (covers ionCube issues):
'http://localhost:88/php/apilicensecheck.php?task=licenseCheck'
{"status":1,"message":"license file key.php expired. Current date: 2021-02-23 Expiration date: 2021-02-16"}
'http://localhost:88/php/apilicensecheck.php?task=licenseCheck'
{"status":0,"message":"License OK."}
  • Test concurrent calls limit (requires functional ionCube):
'http://localhost:88/php/apilicensecheck.php?task=licenseCallsLimitCheck'

Examples:

{"status":1,"message":"You have exceeded the license limit for concurrent calls and the system has been locked. Contact support."}
{"status":1,"message":"You have exceeded the license limit for concurrent calls. The system will be locked in 14 days. Contact support."}
{"status":0,"message":"Limit violation for 2nd consecutive day."}

AI Summary for RAG

Summary: This article covers VoIPmonitor's custom login (LDAP/script examples, parameters), CDR HTTP API (inputs/outputs, examples), sharing CDRs, getting PCAPs, URL searches, HTTP API 2 (getVoipCalls, recordings, active calls, reports, shares, PCAPs, CDR lists, audio graphs), direct links, SIP history retrieval, and license checks.

Keywords: custom login, LDAP, CDR API, HTTP API, getVoipCalls, getVoiceRecording, active calls, reportSummary, getShareURL, getPCAP, SIP history, license check

Key Questions:

  • How to implement custom login in VoIPmonitor?
  • What parameters does the CDR HTTP API support?
  • How to share CDRs via API?
  • What is HTTP API 2 and its methods?
  • How to retrieve SIP history?
  • How to check VoIPmonitor license via API?