Sarv.com

Click to Call API

https://s-ct3.sarv.com/clickToCall/v1/para

PHP Example:


 <?php
$curl = curl_init();

$USER_ID = "USER_ID";
$TOKEN = "TOKEN";
$FROM = "FROM_NUMBER";
$TO = "TO_NUMBER";

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://s-ct3.sarv.com/clickToCall/v1/para?user_id=$USER_ID&token=$TOKEN&from=$FROM&to=$TO",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
 ?> 

            

cURL Example:


 curl -X POST \
  'https://s-ct3.sarv.com/clickToCall/v1/para?user_id=USER_ID&token=TOKEN&from=FROM_NUMBER&to=TO_NUMBER' \
  -H 'cache-control: no-cache'

            

NodeJS Example:


var request = require("request");

var options = { method: 'POST',
  url: 'https://s-ct3.sarv.com/clickToCall/v1/para',
  qs: 
   { user_id: 'USER_ID',
     token: 'TOKEN',
     from: 'FROM_NUMBER',
     to: 'TO_NUMBER' },
  headers: 
   { 'cache-control': 'no-cache' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

            
Parameters (* compulsory field)
user_id* integer A valid user id
token* string A valid campaign token
from* integer
Based on the value in fromType, it could be a valid phone number or a valid agent id or a valid group id.
You can also provide multiple comma values if fromType is Number or Agent. You can pass upto 5 numbers.
Number mentioned in from will be called first. Once it will answer, system will call the number mentioned in to
example
from=98765XXXXX
from=98765XXXXX,99887XXXX
to* integer
Based on the value in toType, it could be a valid phone number or a valid agent id or a valid group id.
You can also provide multiple comma values if toType is Number or Agent. You can pass upto 5 numbers.
Number mentioned in to will be called once from number answers
example
from=98765XXXXX
from=98765XXXXX,99887XXXX
Parameters (optional field)
fromType string
Possible Values
Number
Agent
Group
Default : Number
fromStrategy string
If fromType is number or agent then from can have multiple values. In that case calling strategy can be defined. Calling strategy means how you want to call these specified numbers.
Possible Values
ONE_BY_ONE
TO_ALL
Default : ONE_BY_ONE
toType string
Possible Values
Number
Agent
Group
Default : Number
toStrategy string
If toType is number or agent then to can have multiple values. In that case calling strategy can be defined. Calling strategy means how you want to call these specified numbers.
Possible Values
ONE_BY_ONE
TO_ALL
Default : ONE_BY_ONE
fromRingTime integer
Ring duration in seconds for from number
example
fromRingTime=20
Maximum value : 50
Default : 20
toRingTime integer
Ring duration in seconds for to number
example
toRingTime=20
Maximum value : 50
Default : 20
timeLimit integer
It is duration in seconds to limit the talk time between from and to
Ring durations of from and to are not included in timeLimit
Call will be disconnected if timeLimitHangup is true
Default : unlimited
timeLimitHangup boolean
If timeLimit is set to more than 0 and timeLimitHangup is true then call will be disconnected after the duration mentioned in timeLimit
Default : true
timeLimtAlert integer
This is duration in seconds
If timeLimit is set then you can play announcements at some specific time to notify the from and to numbers.
This announcement will be heard by both the numbers
Announcement will be played when the talk time is longer than the time mentioned in timeLimtAlert.
Multiple comma separated values can be passed.
example
timeLimtAlert=120,300
alertAudio integer
This is a valid id of announcement. You can find announcement Ids in your account under Manage->Announcement-> Id
Multiple comma separated values can be passed.
If specified, announcement will be played according to timeLimtAlert
example
alertAudio=1610448601_84.wav,1610448601_85.wav
You can pass only one announcement id even if you have passed multiple values in timeLimtAlert. Same id will be played for all.
ringTone string
This is a valid id of announcement. You can find announcement Ids in your account under Manage->Announcement-> Id
If passed, announcement will be heard by from number in loop while dialing to number
If not passed, the original announcement (played by mobile operator) will be heard by from number.
example
ringTone=1610448601_84.wav
fromRetryCount integer
Number of retries on from number
Maximum allowed value : 3
Default : 0
toRetryCount integer
Number of retries on to number
Maximum allowed value : 3
Default : 0
mode string
This parameter is helpful at the time of API integration in your panel.
Possible Values
live : API will respond and originate call as well in case of success
developer : API will respond success/error according to the parameters but call will not originate
Default : live

Response

Success Case :

{
  "callid": "kn5skxr6161770885161627785",
  "status": "success",
  "code": "200" 
}

Error Case :

{
  "message": "Invalid From Type",
  "status": "error",
  "code": "105"
}

Error Codes

Response Code Description
100 Invalid Field
101 user_id not found
102 user_id invalid
103 Token not found
104 Invalid Token
105 fromType empty
106 fromType Invalid
107 toType empty
108 toType Invalid
109 from parameter not found
110 invalid mobile number in from parameter
111 invalid mobile number in to parameter
112 Duplicate Mobile Number exists in from parameter
113 Duplicate Mobile Number exists in to parameter
114 Invalid Agent Id in from parameter
115 Invalid Agent Id in to parameter
116 Duplicate Agent Id Exists in from parameter
117 Duplicate Agent Id Exists in to parameter
118 Multiple Group Ids found in from parameter
119 Multiple Group Ids found in to parameter
120 Invalid Group Id in from parameter
121 Invalid Group Id in to parameter
122 Same value exists in from and to parameters
123 from and to parameters are empty
124 fromStrategy invalid
125 toStrategy invalid
126 fromRingTime value invalid
127 negative value not allowed for fromRingTime
128 toRingTime value invalid
129 negative value not allowed for toRingTime
130 fromRetryCount value invalid
131 negative value not allowed for fromRetryCount
132 toRetryCount value invalid
133 negative value not allowed for toRetryCoun
134 timeLimit empty
135 negative value not allowed for timeLimit
136 timeLimit value invalid
137 ringTone invalid announcement id
138 fromWebLogin no anyone agent found
139 fromWebLogin no anyone Group Agent found
140 fromCallLogin no anyone Agent found
141 fromCallLogin no anyone Agent found
142 fromCallLogin no anyone Group Agent found
143 toWebLogin no anyone Agent found
144 toWebLogin no anyone Agent found
145 toWebLogin no anyone Group Agent found
146 toCallLogin no anyone Agent found
147 toCallLogin no anyone Group Agent found
148 timeLimtAlert invalid
149 alertAudio invalid announcement id
150 Connection Issue
151 timeLimitAlert must be less than timeLimit
152 crossed maximum limit of fromRetryCount
153 crossed maximum limit of toRetryCount
154 crossed maximum limit of fromRingTime
155 crossed maximum limit of toRingTime
156 crossed maximum limit of from parameter
157 crossed maximum limit of to parameter