Introduction

The API is used to connect CRM systems to our global PBX systems based on Asterisk. We have added sets of requests and webhooks to allow clients to submit calling commands and receive updates during the call process. The API will provide real-time connection and disconnection webhooks, allowing the client real-time communication as well as CDR (Call Detail Record) information. Additionally, the ANI (Automatic Number Identification) being used is also provided.

The following methods empower your service with CallExchange features. You can request additional features by contacting our development team. The CallExchange API is a white-label VoIP PBX solution. The API is based on Perl for a robust, faster, and more user-friendly Asterisk gateway interface interaction.

Getting Started

1. Read the following documentation.

2. Get a unique API key from Callexchange for your own leased PBX

3. Keep your private key in a safe place and don't share it with anyone

4. Register on CallExchange.net   if you don't have an account yet.

Contact us via Telegram at @callexchange to complete any missing details.

Protocol

CallExchange API uses JSON-RPC 2.0 protocol.

Issue a Call

POST asteriskapi

Attach the parameters to issue an outgoing call.

HTTP Request

https://{{pbx_name}}.callexchange.net/api/v1/asteriskapi

Request

Request
Payload
cURL
Header Parameters (java)
Name Type Required Description
api-key string True Your API key (SHA256 from Public Key)
application/json
{ " extension " : "2001", " destination ": "12127773456", " voice_pitch ": "1", " call_in_out ": “dialer option” " msg ": “some text to be send to softphone application” }
curl --request POST {{pbx_name}}.callexchange.net/api/v1/ asteriskapi \
--header 'api-key: {{apiKey}}' \

--data-raw '{
    {
    " extension " : "2001",
    " destination " : "12127773456",
    " voice_pitch " : "1",
    " call_in_out " : “true”
    " msg “ : “some text to be send to softphone application”
    }
}'
Name Type Required Description
extension string True The agent extension.
destination string True The destination number you are dialing.
voice_pitch float false Changing the agent voice values are 0.1-2.0
call_in_out bolean false Design for auto dialer first call agent then lead or vise versa.
Msg text false Message to be sent to the softphone.

Sample Response.

application/json

{
  status : "true",
  icon : "DE",
  message : "Success making a call",
  phone_valid : yes,
  country_code : 49,
  carrier : 

‘deutsche telekom’,

caller_id : 442012345678, check_spam : "true", }

Success

Response Params.

Name Type Description
status boolean True on making an outgoing call.
icon string success or not.
message text About being able to make a call.
phone_valid boolean Checking weather phone is compatible with E.164 format which means valid number.
country_code int Country code about destintion for example display a flag of the country you are calling.
carrier string The lead destination carrier name.
caller_id string What is the ANI being used to initiate the call.
check_spam boolean System making sure the call is not flagged spam on the destination phone.
error:

  status : 400 Bad Request,
      icon : "error",
      error : "Missing parameters: api-key, extension, or destination"
  message : We fail on making a call. caller : $extension, callee : $destination,

Recorded Calls

GET find_phone_files

Attach the parameters to issue an outgoing call.

HTTP Request

https://{{pbx_name}}.callexchange.net/recorded/v1/find_phone_files

Request

Request
Payload
cURL
Header Parameters (java)
Name Type Required Description
api-key string True Your API key (SHA256 from Public Key)
application/json

{
  "phone" : "12127773456",
}
curl --request POST {{pbx_name}}.callexchange.net/recorded/v1/find_phone_files\
--header 'api-key: {{apiKey}}'\

--data-raw '{
    {
    "phone" : "12127773456",
    }
}'
Name Type Required Description
phone string True The lead phone number.

Sample Response.

  application/json
  
[
    {
        "url" : "https://pbx.callexchange.net/wav-files/2024/07/03/out-12127773456-unknown-20240703-203742-1720039056.22191.wav",
        "time" : "20:37:42",
        "duration" : 25,
        "date" : "03/07/2024"
     },
    {
        "url" : "https://pbx.callexchange.net/wav-files/2024/07/08/out-12127773456-unknown-20240703-201330-1720037603.22173.wav",
        "time" : "20:13:30",
        "duration" : 918,
        "date" : "08/07/2024"
     },
    {
        "url" : "https://pbx.callexchange.net/wav-files/2024/07/12/out-12127773456-unknown-20240703-150403-1720019043.21754.wav",
        "time" : "15:04:03",
        "duration" : 714,
        "date" : "12/07/2024"
     },
]

Success

Response Params.

Name Type Description
url string The full url for the call.
date string Date of the call.
time string Time of the call.
duration int Duration of the call in seconds.
  error:
  
  status : 400 Bad Request,
      icon : "error",
      error : "Missing parameters: api-key or phone"

Web Hook

Introduction

The webhook POST requests allow the client CRM to receive updates during the call process. This includes the time when the call was connected and when the call was hung up. This system enables the CRM to monitor calls in real time and build their own CDR system for monitoring and billing.

Note:

The client using the PBX needs to define the URL for the webhook POST requests. Without the exact URL, the PBX cannot update the CRM system. In the current version, the URL is hard-coded when you integrate with the PBX, as it is a leased-based solution.

The CRM client needs to use the time of the webhook request, since it is a synchronous request, to compare the information with their real-time database, detect the correct call, and mark it as answered.

curl --request POST client_crm_url(
  Content_Type => 'application/json',
  Content => encode_json (
        {
          dialed_number => $dialed_number,
          extension => $extension,
          caller_id => $caller_id,
          uniqueid => $uniqueid
        }
    )
);

The CRM client needs to use the time of the webhook request, since it is a synchronous request, to compare the information with their real-time database, detect the correct call, and mark it as hung up.

  curl --request POST client_crm_url(
    Content_Type => 'application/json',
    Content => encode_json (
          {
            dialed_number => $dialed_number,
            extension => $extension,
            duration => $duration,
            caller_id => $caller_id,
            uniqueid => $uniqueid
          }
      )
  );