Common API

Obtain authorization token interface

Interface Description

Tokens required to access other interfaces must be obtained from this interface through the authorized Appid and Accesskey (except for the batch IVR interface). The timeliness of the interface authorization Token is 12 hours.

Request method

POST, form-data format

request parameters

parameter name type Is it necessary illustrate
appid string yes authorized appid
accesskey string yes authorized accesskey
service string yes App.Sip_Auth.Login

Interface request example(PHP)

<?php
    $apiUrl = 'http://127.0.0.1:8080';
    $postFields = [
    'service'    => 'App.Sip_Auth.Login',
    'appid'      => 'ABCDEFG',
    'accesskey'  => 'ABCDEFG',
    ];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $apiUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    $curlError = curl_error($curl);
    curl_close($curl);
    var_dump($response);
?>

Return Data Example

{
    "ret":200,
    "data":{
        "status":0,
        "desc":"Authorization successful",
        "result":{
            "companycode":"1",
            "companyname":"test",
            "token":"773a70dd02f0695d50205e9b267692b9",
            "authtime":"2020-01-01 00:00:00",
            "authmodel":""
        },
        "reqtime":1581240882,
        "rsptime":1581240882
    },
    "msg":""
}

Return parameter description

parameter name type illustrate
companycode int Company code
companyname string Company Name
token string Authorization token, used to access other interfaces

Clear the Token interface

Description

Note: When there is a new extension or an abnormality occurs after the extension is adjusted, you can clear the Token through this interface, and then obtain the Token again to continue the operation.

Request method: POST, form-data format

request parameters

parameter name type Is it necessary illustrate
service string yes App.Sip_Auth.Logout
token string yes Token string

Interface request example(PHP)

<?php
    $apiUrl = 'http://127.0.0.1:8080';
    $postFields = [
        'service'   => ' App.Sip_Auth.Logout',
        'token'     => 'ABCDEFG',
    ];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $apiUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    $curlError = curl_error($curl);
    curl_close($curl);
    var_dump($response);
?>

return data structure example

{
    "ret": 200,
    "data": {
        "status": 0,
        "desc": "logout successful",
        "reqtime": 1602655204,
        "rsptime": 1602655204
    },
    "msg": ""
}

Global error and status codes

Interface exception error

Description: ret is not 200, msg is abnormal error message.

{
    "ret":400, // status code
    "data":[],
    "msg":"Illegal request: invalid parameter"
}

ret msg illustrate
400 illegal request Generally, the parameters are invalid
500 Server Error
600 The token is invalid, please log in again to verify
601 appid is not authorized Please check the appid or contact Yunhu Technology for authorization
602 appid authorization has expired
603 Module not licensed
604 IP is not authorized Please contact the manufacturer to authorize access

The interface request is normal, but the internal processing error

Description: ret is 200. In the data structure, the status is 1, desc is the Chinese description of the failure, and errors is the detailed error information. For the code code, please refer to the corresponding description. msg is empty.

{
    "ret": 200,
    "data": {
        "status": 1,
        "desc": "xxxfail",
        "errors": {
            "code": "1003",
            "codemsg": "Authorization failed"
        },
        "reqtime": 1507529858,
        "rsptime": 1507529858
    },
    "msg": ""
}

code codemsg illustrate
1001 Server connection failed Usually due to network
1002 Abnormal operation Generally, it is a check exception, etc.
1003 operation failed Generally, authorization failure, logout failure, command sending failure, server connection exception, etc.
1010 Extension exception It may be a newly added extension, you need to log in again to get a new token
1011 illegal extension not owned by the company
1012 extension does not exist Extension Number Status
1013 extension disabled Extension Number Status
1014 extension not registered Extension Number Status
1015 The extension is not in a call Extension Number Status
1016 extension enabled Extension Number Status
1017 extension is registered Extension Number Status
1018 Number is enabled Caller ID status
1019 number disabled Caller ID status
1020 number does not exist Caller ID status
1021 illegal number not owned by the company
1024 task does not exist Predictive task interface return status
1025 has not started Predictive task interface return status
1026 in progress Predictive task interface return status
1027 pause Predictive task interface return status
1028 over Predictive task interface return status
1201 idle Extension is legal, enabled and registered
1202 ringing extension return
1203 off-hook extension return
1204 calling extension return
1205 User rejects Called party rejects
1210 Queue exception return in predictive outbound
1211 illegal queue Does not exist or is not owned by the company
1212 did not answer Assigned unanswered
1213 Waiting Waiting for assignment (idle)
1214 receiving Status of extensions in queue
1215 answered Status of extensions in the queue
1216 Reject Status of extensions in the queue
1217 pause show busy
1218 checked in The extension is already checked into the queue
10001 hang up normally call state
10002 call cancel call state
10003 refuse to answer call state
10004 Outbound channel line failure Usually due to wiring
10005 User timed out call state
10006 User is busy
10007 Server Hangup call state
10008 Extension Not Registered call state
10009 Destination Unreachable call state
10011 Timer Timeout call state
10012 Inbound Callback Interface Error call state
10013 Extension Does Not Exist call state
10014 Not Found call state
10015 Request Timeout call state
10016 No Answer call state
10017 Call Invalid call state
10019 Origin Unknown call state
10020 Other Reason call state
10024 Bad Request call state
10025 Call Forbidden call state
10027 Number Changed call state
10028 Call Intercepted call state
10031 Unknown call state
10040 caller hang up call state
10041 Called hang up call state

Extension call state callback parameters

Description

To call back the call status of an extension, you need to configure a callback address for the corresponding account. Callback address configuration for extension call status: The customer provides an interface address that can receive json data, which can be configured by us or by the customer in the background.

Extension call status callback data format

{
"buuid":"526d643a-e8fe-11ea-a84a-cf6e45e88543",
"callee":"87847569524",
"caller":"90240005",
"companycode":"9024",
"customuuid":"123Abc",
"direction":"callout",
"disnumber":"2190240001",
"extnumber":"90240005",
"isbleg":"false",
"method":"3",
"starttime":"1598598959",
"status":"ring",
"type":"call",
"uuid":"526d637c-e8fe-11ea-a849-cf6e45e88543"
}

Explanation of extension call status callback parameters

parameter name type illustrate
buuid string The uuid of the called number on side b of the call
callee int called number
caller int calling number
companycode int The company id corresponding to the account
customuuid string Custom parameter - customer id
direction string Call direction: 1. Incoming; 2. Outgoing;
disnumber int Destination number to call
extnumber int Ext
isbleg string true is ringing on the mobile phone side; false is ringing on the seat side;
method string Call method: 0, unlimited; 1, mutual extension dial; 2, extension direct dial; 3, API call (default); 4, API double call; 5, predictive outbound call; 6, IVR/group call.
starttime string call time
status string call type
type string call type
uuid string call uuid

Call record callback parameters

Description

Bill callback needs to be configured with a callback address for the corresponding account. Callback address configuration of bills: The customer provides an interface address that can receive json data, which can be configured by us or configured by the customer in the background.

Call record callback data format json

{
    "callmethod": 3, 
    "starttime": "2018-03-14 12:18:21", 
    "answertime": "", 
    "endtime": "2018-03-14 12:18:35",  
    "duration": 14,  
    "billsec": 0, 
    "crmid": "2001", 
    "hangupdirection": 10015, 
    "chengshudu": "0", 
    "hangupcause": 10001, 
    "memberid": "18533700187590656",  
    "disnumber": "02566823420",  
    "destnumber": "015029913692",  
    "downloadip": "120.76.152.137", 
    "recordfilename": "",  
    "companycode": 20000013,  
    "type": "callout",  
    "id": 982, 
    "extnumber": "7003" 
    "uuid": "cda5c6c4-0a17-11e8-b177-e7cbf2bd1f36" 
    "userkey":1  
    "customuuid": "customuuid"  
}

Description of Call Record Callback Parameters

parameter name type illustrate
callmethod int Call method: 0, unlimited; 1, mutual extension dial; 2, extension direct dial (manual dial); 3, API call (default); 4, API double call; 5, predictive outbound call; 6, IVR/group call .
starttime string call time
answertime string response time
endtime string call end time
duration int call waiting time
billsec int call time
crmid string employee number
hangupdirection int On-hook direction 10040 Caller、10041 Callee
chengshudu string Custom Parameters - Maturity
hangupcause int Hangup Reason Code 10001:Normal Hangup、10002:Call Canceled、10003:Call Rejected、10004:Outbound Channel Line Failure、10005:User Did Not Answer (Timeout)、10006:User Busy
memberid string Custom parameter - member id
disnumber string calling number
destnumber string called number
downloadip string recording download ip
recordfilename string recording file name
companycode string company id
type string call type
extnumber string Ext
uuid string call uuid
userkey string user button
customuuid string Custom parameter - customer id

Call recording download link interface

Interface Description

Get the download link for the call log file. At present, call recordings are saved for 3 months, and it is recommended to save them locally。

request parameters

parameter name type Is it necessary illustrate
service string yes App.Sip_Cdr.GetRecodeFile
token string yes The token obtained through the authorization interface
filename string yes The recording file name returned in the call recording callback

Interface request example(PHP)

<?php
    $apiUrl = 'http://127.0.0.1:8080';
    $postFields = [
        'service'   => 'App.Sip_Cdr.GetRecodeFile',
        'token'     => 'ABCDEFG',
        'filename'  => 'abcdefg',
    ];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $apiUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    $curlError = curl_error($curl);
    curl_close($curl);
    var_dump($response);
?>

return data structure example

{
    "ret": 200,
    "data": {
        "status": 0,
        "desc": "get success",
        "result": {
            "downurl": "http://127.0.0.1:8080/abcdefg",
            "expiredtime": "Expiration time:2020-02-11 17:27:23"
        },
        "reqtime": 1581412943,
        "rsptime": 1581412943
    },
    "msg": ""
}

Return parameter description

parameter name type illustrate
result objest returned result set
downurl string Call recording file download link
expiredtime string Download link expiration time