Table of Contents

Listing Active Calls

You can get all active calls. It helps to show active calls at any 3th party software.

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=activecalls
				
			

Sample: http://iexpbx.com/api/old/get?username=TESTUSER&password=TESTPASSWORD&action=activecalls

Result Example
				
					[
   {
      "success": true,
      "count": 1,
      "data": [
         {
            "channel": "SIP/trunk-sip-Trunk110-36a9b",
            "duration": "00:01:14",
            "calltype": "Queue(630)",
            "callinfo": "Talking",
            "src": "9053xxxxxxxxx",
            "dst": "110"
         }
      ]
   }
]
				
			
Definations

channel= It is a unique value that distinguishes the call. It helps to learn call id in order to download call record.

duration= Call duration

calltype= Call type

callinfo= Current call status

src= Caller

dst= Called

Delphi Code
				
					Var
JSONObject, Veriler: TJsonObject;
VeriArray: TJSONArray;
don:Integer;
Begin
JSONObject         := TJsonObject.Create;
    try
     JSONObject.Parse(TEncoding.UTF8.GetBytes(NetHTTPCagriDetaylari.Get(' http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=activecalls’).ContentAsString), 1);
     if StrToInt(JSONObject.GetValue('count').Value)<>0 then
     Begin
       VeriArray := JSONObject.GetValue('data') as TJSONArray;

         for don := 0 to VeriArray.Count-1 do
         begin
                Veriler := TJsonObject.Create;
                try
                  Veriler.Parse(TEncoding.UTF8.GetBytes(VeriArray.Items[don].ToString), 0);
                      UniMemo1.Lines.Add(Veriler.GetValue('channel').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('duration').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('calltype').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('callinfo').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('src').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('dst').Value);
                  finally
                      Veriler.Free;
                 end;
         end;
     End;
      finally
          JSONObject.Free;
     end;
end;
				
			
Java Script Code
				
					function activecalls(j){
        var rjson=JSON.parse(j);
        if (rjson.success==true){
            for (var i = 0; i < rjson.count; i++) {
            var counter = rjson.data[i];         
            console.log("data: "+ (i+1));
            console.log("channel: "+ rjson.data[i].channel);
            console.log("duration: "+ rjson.data[i].duration);
            console.log("calltype: "+ rjson.data[i].calltype);
            console.log("callinfo: "+ rjson.data[i].callinfo);
            console.log("src: "+ rjson.data[i].src);
            console.log("dst: "+ rjson.data[i].dst);
        }
        else 
        {
            console.log('error');
        }
                }

				
			
C# Code
				
					using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

void jsonparse(string json)
        {
            int count = 0;
            string channel, duration, calltype, callinfo, src, dst, success;
            var myJObject = JObject.Parse(json);
            success = myJObject.SelectToken("success").Value<string>();
            if (success == "True")
            {
                count = myJObject.SelectToken("count").Value<int>();
                if (count > 0)
               {
                    JToken[] data = myJObject["data"].ToArray();
                    for (int i = 0; i < count; i++)
                    {
                        var dataparse = JObject.Parse(data[i].ToString());
                        channel = dataparse.SelectToken("channel").Value<string>();
                        duration = dataparse.SelectToken("duration").Value<string>();
                        calltype = dataparse.SelectToken("calltype").Value<string>();
                        callinfo = dataparse.SelectToken("callinfo").Value<string>();
                        src = dataparse.SelectToken("src").Value<string>();
                        dst = dataparse.SelectToken("dst").Value<string>();
                    }
                }
            }
        }
				
			

Hang up call

You can hang up any active call. 

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=hangupcall& channel={CHANNELNAME}
				
			

Listing Call details

You can get call details of all calls which is defined by datetime

				
					http://example.com/api/old/get?username=APISUSERNAME&password=APIPASSWORD&action=cdr&date1={ ddMMyyyyhhmm)&date2={ddMMyyyyhhmm}&number=&uf=yes
				
			

Sample: http://example.com/api/old/get?username=APISUSERNAME&password=APIPASSWORD&action=cdr&date1=030920190100&date2=030920191500&number=90507XXXXXXX&uf=yes

Result Example
				
					[
   {
      "success": true,
      "count": 3,
      "data": [
         {
            "id": "28699",
            "calldate": "03.09.2019 12:30:38",
            "calltype": "incoming",
            "src": "90507XXXXXXX",
            "dst": "101",
            "duration": "85,6972",
            "disposition": "ANSWERED",
            "queue": "",
            "record": true,
            "userfield": "Test data"
         },
         {
            "id": "68871",
            "calldate": "03.09.2019 11:31:54",
            "calltype": "outcoming",
            "src": "100",
            "dst": "9050XXXXXXXX",
            "duration": "4,39364",
            "disposition": "BUSY",
            "queue": "",
            "record": true,
            "userfield": "Test data"
         },
         {
            "id": "28674",
            "calldate": "03.09.2019 10:13:11",
            "calltype": "incoming",
            "src": "905XXXXXXXX",
            "dst": "100",
            "duration": "28,382",
            "disposition": "NO ANSWER",
            "queue": "630",
            "record": false,
            "userfield": "Test data"
         }
      ]
   }
]
				
			
Definations

id= It is a unique value that distinguishes the call. It helps to learn call id in order to download call record.

calldate= Datetime

duration= Call duration

calltype= Call type

src= Caller

dst= Called

disposition= Call result

queue= Queue number

record= Data whether there is a voice recording or not

uf= (Optional) Set it yes if you need to list datas which has been sent by auto IVR call

Delphi Code
				
					Var
JSONObject, Veriler: TJsonObject;
VeriArray: TJSONArray;
don:Integer;
Begin
JSONObject         := TJsonObject.Create;
    try
     JSONObject.Parse(TEncoding.UTF8.GetBytes(NetHTTPCagriDetaylari.Get(' http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=cdr&date1=030920190100&date2=030920191500&number=’).ContentAsString), 1);
     if StrToInt(JSONObject.GetValue('count').Value)<>0 then
     Begin
       VeriArray := JSONObject.GetValue('data') as TJSONArray;

         for don := 0 to VeriArray.Count-1 do
         begin
                Veriler := TJsonObject.Create;
                try
                  Veriler.Parse(TEncoding.UTF8.GetBytes(VeriArray.Items[don].ToString), 0);
                      UniMemo1.Lines.Add(Veriler.GetValue(id).Value); 
                      UniMemo1.Lines.Add(Veriler.GetValue('calldate').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('calltype').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue(src).Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('dst').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('duration').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('disposition').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('queue').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('record').Value);
                  finally
                      Veriler.Free;
                 end;
         end;
     End;
      finally
          JSONObject.Free;
     end;
end;
				
			
Java Script Code
				
					function calldetails(j){
        var rjson=JSON.parse(j);
        if (rjson.success==true){
            for (var i = 0; i < rjson.count; i++) {
            var counter = rjson.data[i];         
            console.log("id: "+ rjson.data[i].id);
            console.log("calldate: "+ rjson.data[i].calldate);
            console.log("calltype: "+ rjson.data[i].calltype);
            console.log("src: "+ rjson.data[i].src);
            console.log("dst: "+ rjson.data[i].dst);
            console.log("duration: "+ rjson.data[i].duration);
            console.log("disposition: "+ rjson.data[i].disposition);
            console.log("queue: "+ rjson.data[i].queue);
            console.log("record: "+ rjson.data[i].record);
        }
        else 
        {
            console.log('error');
        }
                
                }

				
			
C# Code
				
					using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

void jsonparse(string json)
        {
            int count = 0;
            string id, calldate, calltype, src, dst, duration, disposition, queue, record, success;
            var myJObject = JObject.Parse(json);
            success = myJObject.SelectToken("success").Value<string>();
            if (success == "True")
            {
                count = myJObject.SelectToken("count").Value<int>();
                if (count > 0)
               {
                    JToken[] data = myJObject["data"].ToArray();
                    for (int i = 0; i < count; i++)
                    {
                        var dataparse = JObject.Parse(data[i].ToString());
                        id = dataparse.SelectToken("id").Value<string>();
                        calldate = dataparse.SelectToken("calldate").Value<string>();
                        calltype = dataparse.SelectToken("calltype").Value<string>();
                        src = dataparse.SelectToken("src").Value<string>();
                        dst = dataparse.SelectToken("dst").Value<string>();
                        duration = dataparse.SelectToken("duration").Value<string>();
                        disposition = dataparse.SelectToken("disposition").Value<string>();
                        queue = dataparse.SelectToken("queue").Value<string>();
                        record = dataparse.SelectToken("record").Value<string>();

                    }
                }
            }
        }

				
			

Listing Extensions

You can get extansions details and their register statuses

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=users
				
			
Result Example
				
					[
   {
      "success": true,
      "count": 3,
      "data": [
         {
            "username": "100",
            "name": "John",
            "regstatus": "OK (93 ms)"
         },
         {
            "username": "101",
            "name": "Marry",
            "regstatus": "OK (109 ms)"
         },
         {
            "username": "102",
            "name": "David",
            "regstatus": "OK (91 ms)"
         }
      ]
   }
]
				
			
Definations

username=Extension number

name=Extension name

regstatus=Register status

Delphi Code
				
					Var
JSONObject, Veriler: TJsonObject;
VeriArray: TJSONArray;
don:Integer;
Begin
JSONObject         := TJsonObject.Create;
    try
     JSONObject.Parse(TEncoding.UTF8.GetBytes(NetHTTPDahili.Get(' http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=users’).ContentAsString), 1);
     if StrToInt(JSONObject.GetValue('count').Value)<>0 then
     Begin
       VeriArray := JSONObject.GetValue('data') as TJSONArray;

         for don := 0 to VeriArray.Count-1 do
         begin
                Veriler := TJsonObject.Create;
                try
                  Veriler.Parse(TEncoding.UTF8.GetBytes(VeriArray.Items[don].ToString), 0);
                      UniMemo1.Lines.Add(Veriler.GetValue(‘username’).Value); 
                      UniMemo1.Lines.Add(Veriler.GetValue('name').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('regstatus').Value);
                  finally
                      Veriler.Free;
                 end;
         end;
     End;
      finally
          JSONObject.Free;
     end;
end;
				
			
Java Script Code
				
					Var
JSONObject, Veriler: TJsonObject;
VeriArray: TJSONArray;
don:Integer;
Begin
JSONObject         := TJsonObject.Create;
    try
     JSONObject.Parse(TEncoding.UTF8.GetBytes(NetHTTPDahili.Get(' http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=users’).ContentAsString), 1);
     if StrToInt(JSONObject.GetValue('count').Value)<>0 then
     Begin
       VeriArray := JSONObject.GetValue('data') as TJSONArray;

         for don := 0 to VeriArray.Count-1 do
         begin
                Veriler := TJsonObject.Create;
                try
                  Veriler.Parse(TEncoding.UTF8.GetBytes(VeriArray.Items[don].ToString), 0);
                      UniMemo1.Lines.Add(Veriler.GetValue(‘username’).Value); 
                      UniMemo1.Lines.Add(Veriler.GetValue('name').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('regstatus').Value);
                  finally
                      Veriler.Free;
                 end;
         end;
     End;
      finally
          JSONObject.Free;
     end;
end;
				
			
C# Code
				
					using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

void jsonparse(string json)
        {
            int count = 0;
            string username, name, regstatus, success;
            var myJObject = JObject.Parse(json);
            success = myJObject.SelectToken("success").Value<string>();
            if (success == "True")
            {
                count = myJObject.SelectToken("count").Value<int>();
                if (count > 0)
               {
                    JToken[] data = myJObject["data"].ToArray();
                    for (int i = 0; i < count; i++)
                    {
                        var dataparse = JObject.Parse(data[i].ToString());
                        username = dataparse.SelectToken("username").Value<string>();
                        name = dataparse.SelectToken("name").Value<string>();
                        regstatus = dataparse.SelectToken("regstatus").Value<string>();
                    }
                }
            }
        }
				
			

Listing Queues

You can get details of queues.

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=queues
				
			
Result Example
				
					[
   {
      "success": true,
      "count": 3,
      "data": [
         {
            "queuenumber": "630",
            "name": "Sale",
            "internal": "100,101,102,103,104"
         },
         {
            "queuenumber": "632",
            "name": "Support",
            "internal": "105,106"
         },
         {
            "queuenumber": "633",
            "name": "Finance",
            "internal": "107,108,109,110,111"
         }
      ]
   }
]
				
			
Definations

queuenumber=Queue number

name=Queue name

internal=Members of queue

Delphi Code
				
					Var
JSONObject, Veriler: TJsonObject;
VeriArray: TJSONArray;
don:Integer;
Begin
JSONObject         := TJsonObject.Create;
    try
     JSONObject.Parse(TEncoding.UTF8.GetBytes(NetHTTPKuyruk.Get(' http://example.com/api/old/get?username=ApiKullanıcıAdı&password=ApiŞifre&action=queues’).ContentAsString), 1);
     if StrToInt(JSONObject.GetValue('count').Value)<>0 then
     Begin
       VeriArray := JSONObject.GetValue('data') as TJSONArray;

         for don := 0 to VeriArray.Count-1 do
         begin
                Veriler := TJsonObject.Create;
                try
                  Veriler.Parse(TEncoding.UTF8.GetBytes(VeriArray.Items[don].ToString), 0);
                      UniMemo1.Lines.Add(Veriler.GetValue(‘queuenumber’).Value); 
                      UniMemo1.Lines.Add(Veriler.GetValue('name').Value);
                      UniMemo1.Lines.Add(Veriler.GetValue('internal').Value);
                  finally
                      Veriler.Free;
                 end;
         end;
     End;
      finally
          JSONObject.Free;
     end;
end;
				
			
Java Script Code
				
					function queuestatus(j){
        var rjson=JSON.parse(j);
        if (rjson.success==true){
            for (var i = 0; i < rjson.count; i++) {
            var counter = rjson.data[i];         
            console.log("data: "+ (i+1));
            console.log("queuenumber: "+ rjson.data[i].queuenumber);
            console.log("name: "+ rjson.data[i].name);
            console.log("internal: "+ rjson.data[i].internal);
        }
        else 
        {
            console.log('error');
        }
                
}
				
			
C# Code
				
					using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

void jsonparse(string json)
        {
            int count = 0;
            string queuenumber, name, internal, success;
            var myJObject = JObject.Parse(json);
            success = myJObject.SelectToken("success").Value<string>();
            if (success == "True")
            {
                count = myJObject.SelectToken("count").Value<int>();
                if (count > 0)
               {
                    JToken[] data = myJObject["data"].ToArray();
                    for (int i = 0; i < count; i++)
                    {
                        var dataparse = JObject.Parse(data[i].ToString());
                        queuenumber = dataparse.SelectToken("queuenumber").Value<string>();
                        name = dataparse.SelectToken("name").Value<string>();
                        internal = dataparse.SelectToken("internal").Value<string>();
                    }
                }
            }
        }
				
			

Start a Call

You can call any number from any extension. This API is used to start an automatic call from third party softwares such as CRM, ERP or etc…

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=callnumber&number={DESTINATION}&internal={EXTENSION}
				
			

Outgoing IVR Call

You can start an outgoing IVR call via this API.

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=callivr&number={DESTINATION}&dp={DIAL_PLAN_NAME}&dest={IVR_NO}&uf={CUSTOM_DATA}&file={TTS_CONTEXT}|ANNOUNCE1|ANNOUNCE2
				
			
Definations

number= Destination number which will be called

dp= Dial plan

dest= IVR number which will be played when call successfully established

uf= Custom data

file= You can specify announcements at here. Multiple TTS contexts and audio files can be used. Please write audio file name (without file extension) to play a file. If you wish to use TTS feature, please place TTS context inside {} tags.

If you want to use TTS feature you should configure related IVR script.

IVR Script sample

				
					procedure baslat;
begin

      Read(tuslama,'${XPLAY}',3,5);
      API(sonuc,'http://www.siteniz.com/api/sms.php?tuslama=${tuslama}&id=${MSTUF}');
      PlayBack('tesekkurler');
      Hangup;

end;
				
			

${XPLAY} ==>Reads the file parameter which has been taken from API code

${MSTUF}==>It gets uf parameters from the API code

Number masking

Number masking helps  to keep privacy of customer and business phone numbers. Callers can only see the caller ID you set, not their actual phone numbers or extensions. You can start a call between two numbers without showing their caller ids to each other.

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=callback&number1={PHONE_NUMBER1}&number2={PHONE_NUMBER2}&dp={DIAL_PLAN_NAME}&uf={CUSTOM_DATA}
				
			

Downloading a call record

You can download any call record. Audio format is .gsm

You must know call id or chanid to download it. These datas can be obtained from call details API.

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=record&id={CALL_ID)
				
			

Getting IEXPBX contacts

IEXPBX has integrated phonebook. You can use IEXPBX contacts inside any software via this API. Result format is XML file.

				
					http://example.com/api/old/get?username=APIUSERNAME&password=APIPASSWORD&action=phonedirectory
				
			
Result Example
				
					<?xml version="1.0" encoding="UTF-8" ?>
<iexIPPhoneDirectory>
    <DirectoryEntry>
        <Name>John Lash</Name>
        <Telephone>908502590259</Telephone>
    </DirectoryEntry>
    
    <DirectoryEntry>
        <Name>David Copper</Name>
        <Telephone>90538XXXXXXX</Telephone>
    </DirectoryEntry>
</iexIPPhoneDirectory>
				
			

Data Sharing via Webhook

You can share all your call trafic details to your CRM or other software. 

API webhook must be set under the following menu: Settings>API Integration>Add API

Sample API settings should be like this;

SENDING CALL INFO WHEN A CALL STARTED

Caller name, called name, did, call type or channel id can be sent to your webhook address when a new call started

				
					https://www.yourcrm.com/caller/datas?caller={src}&called={dst}&chan={chanid}
				
			

SENDING CALL INFO WHEN A CALL HANG UP

Channel id, call satatus and call duration can be sent to your webhook address when a call hang up.

				
					https://www.yourcrm.com/caller/datas?chan={chanid}&callstatus{status}&callduration={duration}
				
			

status: Result of call. Possible status values are: “ANSER”, “BUSY”, “NOANSWER”, “CANCEL” or “CONGESTION”

duration: It is call duration in seconds

chanid: Unique call id