Sarv.com

Click to Call API

https://s-ct3.sarv.com/v2/clickToCall/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/v2/clickToCall/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/v2/clickToCall/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/v2/clickToCall/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.
Number mentioned in from will be called first. Once it will answer, system will call the number mentioned in to
example
from=98765XXXXX
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.
Number mentioned in to will be called once from number answers
example
from=98765XXXXX
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
fromWebLogin String
Can use when fromType is an agent or a group.
Possible Values
yes
no
na
Default : na
fromCallLogin String
Can use when fromType is an agent or a group.
Possible Values
yes
no
na
Default : na
toWebLogin String
Can use when toType is an agent or a group.
Possible Values
yes
no
na
Default : na
toCallLogin String
Can use when toType is an agent or a group.
Possible Values
yes
no
na
Default : na
fromCLI String
Can use Valid CLI of user.
sticky String
Based on the value in fromType and toType, Sticky will work only if either fromType or toType has a number as value, not both.
Possible Values
yes
no
na
stickyTimeType String
Based on the value in sticky, It will work only if sticky has yes as value.
Possible Values
min
hour
day
month
permanent
Default : Day
stickyTimeValue Integer
Default : Integer
stickyAgentBusy String
Based on the value in sticky, It will work only if sticky has yes as value.
Possible Values
retrySame
retryNewSticky
retryTemp
Default : retrySame
queueTimeout Integer
Based on the value in sticky, It will work only if sticky has yes as value.
It will only work if out of toType and fromType at-least one have group as value
Default : 60
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
1002 UserId not provided
1013 Invalid user id
1014 Token not found
1020 Invalid token
1501 Connection Issue
1502 fromType empty
1503 fromType Invalid
1504 toType empty
1505 toType Invalid
1506 from parameter not found
1507 to parameter not found
1508 invalid mobile number in from parameter
1509 invalid mobile number in to parameter
1510 Duplicate Mobile Number exists in from parameter
1511 Duplicate Mobile Number exists in to parameter
1512 Invalid Agent Id in from parameter
1513 Invalid Agent Id in to parameter
1514 Duplicate Agent Id Exists in from parameter
1515 Duplicate Agent Id Exists in to parameter
1516 Multiple Group Ids found in from parameter
1517 Multiple Group Ids found in to parameter
1518 Invalid Group Id in from parameter
1519 Invalid Group Id in to parameter
1520 Same value exists in from and to parameters
1521 from and to are empty
1522 fromStrategy invalid
1523 toStrategy invalid
1524 fromRingTime value invalid
1525 negative value not allowed for fromRingTime
1526 toRingTime value invalid
1527 negative value not allowed for toRingTime
1528 fromRetryCount value invalid
1529 negative value not allowed for fromRetryCount
1530 toRetryCount value invalid
1531 negative value not allowed for toRetryCount
1532 timeLimit empty
1533 negative value not allowed for timeLimit
1534 timeLimit value invalid
1535 ringTone invalid announcement id
1536 fromWebLogin none of the agents have this state
1537 fromWebLogin none of the agents from group have this state
1538 fromCallLogin none of the agents have this state
1539 Invalid format
1540 fromCallLogin none of the agents from group have this state
1541 toWebLogin none of the agents have this state
1542 toWebLogin none of the agents from group have this state
1543 toCallLogin none of the agents have this state
1544 toCallLogin none of the agents from group have this state
1545 timeLimitAlert invalid
1546 alertAudio invalid announcement id
1547 timeLimitAlert must be less than from timeLimit
1548 crossed maximum limit of fromRetryCount
1549 crossed maximum limit of toRetryCount
1550 crossed maximum limit of fromRingTime
1551 crossed maximum limit of toRingTime
1552 crossed maximum limit of from parameter
1553 crossed maximum limit of to parameter
1554 invalid CLI in fromCLI
1555 invalid CLI in toCLI
1556 since fromStrategy=TO_ALL, so fromCallLogin filter will not work
1557 since toStrategy=TO_ALL, so toCallLogin filter will not work
1558 Sticky will only work if out of toType and fromType at-least one have number as value,not both
1559 invalid value of stickyTimeType
1560 invalid value of stickyTimeValue. It must be an integer
1561 sticky parameter must be set for stickyTimeType, stickyTimeValue and stickyAgentBusy
1562 invalid value of stickyAgentBusy
1563 invalid value of queueTimeout. It must be an integer
1564 invalid fromWebLogin value
1565 invalid fromCallLogin value
1566 invalid fromWebLogin value
1567 invalid toCallLogin value
1568 queueTimeout will only work if out of toType and fromType at-least one have group as value
1569 Value length exceed 50 characters
1570 Invalid DND Filter Value, valid:from/to/both
1571 Invalid From Type for DND Checking
1572 Invalid To Type for DND Checking
1573 DND number exists in from
1574 DND number exists in to
1575 connection Error in DND Api
1576 Multiple values not allowed in from
1577 Multiple values not allowed in to
1578 From-Agent is not available
1579 To-Agent is not available
1580 Invalid fromType for AGENT_CLI
1581 Invalid toType for AGENT_CLI
1582 From-AGENT_CLI not found
1583 To-AGENT_CLI not found
1584 There should be at-least one agent either in TO or FROM
1585 fromCLI can not be set as AGENT_CLI if toType is group