Launch click to call

This method allows you to start a click-to-call toward multiple destinations.

Resource

https://api.infobip.com/voice/ctc/1/send

Parameters

Property name Type Description
bulkid string The ID which uniquely identifies the request.
messageId string The ID that uniquely identifies the established call.
from string Numeric sender ID in E.164 format. Will be shown to "destinationA".
fromB string Numeric sender ID in E.164 format. If set, it will be shown to "destinationB". If not set, "from" or "destinationA" will be shown to "destinationB", depending on the value of "anonymization".
destinationA string Original destination address. Address must be in the international format (Example: 41793026727).
destinationB string Destination address to which the call will be transferred after successful answering. Address must be in the international format (Example: 41793026727).
text string Text of the message that will be played before call transfer.
language string

If the message is in text format, languages in which the message is written must be defined for correct pronunciation. In the Languages section you can find the list of languages that we support.

audioFileUrl string Besides the text format of the message played before call transfer, audio recording (in waw or mp3 format) can also be delivered. Audio file must be uploaded online so the existing URL can be available for the file download. Size of the audio file must be below 4 MB.
record string Record the call and expose it to client as URL inside the delivery report. Can be true or false.
anonymization boolean Deafult value is false. 
If set, same numeric sender (defined in "from") is used for both calls (towards "destinationA" and "destinationB").
If not set, "destinationA" will be shown to "destinationB". 
If "fromB" is set up, "anonymization" will not be applied; "from" will be shown to "destinationA" and "fromB" will be shown to "destinationB".
notifyUrl string The URL on your callback server on which the Delivery report will be sent.
notifyContentType string Preferred Delivery report content type. Can be application/json or application/xml.
maxDuration int Maximum duration of transferred call in seconds. If set, when maxDuration is reached call will be terminated.
warningTime int

Time before the end of the transferred call, in seconds, when warning beep sound will be played. For example, if maxDuration is set to 60 and warningTime is set to 5, this means that warning beep will be played on 55. second of the transferred call, or 5 seconds before it's end.

retry object Used to define if the delivery of the Voice messages should be retried in case the first try doesn't succeed. Additional retries will be made according to the schedule defined by minPeriod and maxPeriod parameters and platform's internal retry logic. If the minPeriod differs maxPeriod, delivery will be retried in the following manner: after 1 min, 2 min, 5 min, 10 min, 20 min, 30 min, 1 hour, 2 hours, 4 hours, 8 hours, 16 hours, 24 hours or until maxPeriod is reached.  If the retry attempt for the MaxPeriod is reached, the MaxPeriod will be used for all subsequent retries. If the minPeriod and the maxPeriod are defined as equal values, the period of time between retries will be equal to this value. Message delivery will be retried until the successful delivery or message validity or maxCount value is reached.
minPeriod int Defines the minimal waiting time (in minutes) after the previous failed attempt to try to deliver the message again.
maxPeriod int Defines the maximum waiting time (in minutes) after the previous failed attempt to try to deliver the message again.
maxCount int Specify the maximum number of retry attempts. Maximum value of the maxCount is 4. Higher value, if entered will be set to 4.

Request Example

					POST /voice/ctc/1/send HTTP/1.1
Host: {base_url}
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
   "bulkId": "BULK-ID-123-xyz",
   "messages": [
      {
         "messageId": "MESSAGE-ID-123-xyz",
         "from": "41793026700",
         "fromB": "41793026701",
         "destinationA": "41793026727",
         "destinationB": "41793026731",
         "text": "Test Voice message.",
         "language": "en",
         "anonymization": false,
         "notifyUrl": "https://www.example.com/voice/clicktocall",
         "notifyContentType": "application/json",
         "maxDuration": 60,
         "warningTime": 5,
         "retry": {
            "minPeriod": 1,
            "maxPeriod": 5,
            "maxCount": 5
         }
      }
   ]
}
					
				
					curl -X POST \
 http:// \
 -H 'cache-control: no-cache' \
 -H 'postman-token: ee3cf632-75b7-6580-c54b-f1368240be58' \
 -d 'POST /voice/ctc/1/send HTTP/1.1
Host: {base_url}
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
  "bulkId": "BULK-ID-123-xyz",
  "messages": [
   {
     "messageId": "MESSAGE-ID-123-xyz",
     "from": "41793026700",
     "destinationA": "41793026727",
     "fromB":"41793026701",
     "destinationB": "41793026731",
     "text": "Test Voice message.",
     "language": "en",
     "anonymization": false,
     "notifyUrl": "https://www.example.com/voice/clicktocall",
     "notifyContentType": "application/json",
     "maxDuration": 60,
     "warningTime": 5,
     "retry": {
      "minPeriod": 1,
      "maxPeriod": 5,
      "maxCount": 5
     }
   }
  ]
}
					
				
					<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://{base_url}/voice/ctc/1/send",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{
    \"bulkId\": \"BULK-ID-123-xyz\",
    \"messages\": [
      {
        \"messageId\": \"MESSAGE-ID-123-xyz\",
        \"from\": \"41793026700\",
        \"destinationA\": \"41793026727\",
        \"fromB\":\"41793026701\",
        \"destinationB\": \"41793026731\",
        \"text\": \"Test Voice message.\",
        \"language\": \"en\",
        \"anonymization\": false,
        \"notifyUrl\": \"https://www.example.com/voice/clicktocall\",
        \"notifyContentType\": \"application/json\",
        \"maxDuration\": 60,
        \"warningTime\": 5,
        \"retry\":
          {            
            \"minPeriod\": 1,
            \"maxPeriod\": 5,
            \"maxCount\": 5     
          } 
        }
        ]
    
  }",
  CURLOPT_HTTPHEADER => array(
    "authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=",
    "content-type: application/json",
  ),
));

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
					
				
					require 'uri'
require 'net/http'

url = URI("https://{base_url}/voice/ctc/1/send")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ='
request["content-type"] = 'application/json'
request.body = "{
  \"bulkId\": \"BULK-ID-123-xyz\",
  \"messages\": [
    {
      \"messageId\": \"MESSAGE-ID-123-xyz\",
      \"from\": \"41793026700\",
      \"destinationA\": \"41793026727\",
      \"fromB\":\"41793026701\",
      \"destinationB\": \"41793026731\",
      \"text\": \"Test Voice message.\",
      \"language\": \"en\",
      \"anonymization\": false,
      \"notifyUrl\": \"https://www.example.com/voice/clicktocall\",
      \"notifyContentType\": \"application/json\",
      \"maxDuration\": 60,
      \"warningTime\": 5,
      \"retry\": {
        \"minPeriod\": 1,
        \"maxPeriod\": 5,
        \"maxCount\": 5
        }     
      }
      ]}"

response = http.request(request)
puts response.read_body
					
				
					import http.client

conn = http.client.HTTPSConnection("{base_url}")

payload = "{
  \"bulkId\": \"BULK-ID-123-xyz\",
  \"messages\": [
    {
      \"messageId\": \"MESSAGE-ID-123-xyz\",
      \"from\": \"41793026700\",
      \"destinationA\": \"41793026727\",      
      \"fromB\":\"41793026701\",
      \"destinationB\": \"41793026731\",
      \"text\": \"Test Voice message.\",
      \"language\": \"en\",
      \"anonymization\": false,
      \"notifyUrl\": \"https://www.example.com/voice/clicktocall\",
      \"notifyContentType\": \"application/json\",
      \"maxDuration\": 60,
      \"warningTime\": 5,
      \"retry\": {
        \"minPeriod\": 1,
        \"maxPeriod\": 5,
        \"maxCount\": 5
        }  
      }
      ]
      }"

headers = {
    'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=",
    'content-type': "application/json",
    }

conn.request("POST", "/voice/ctc/1/send", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
					
				
					HttpResponse<String> response = Unirest.post("https://{base_url}/voice/ctc/1/send")
  .header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=")
  .header("content-type", "application/json")
  .body("{
         \"bulkId\": \"BULK-ID-123-xyz\",
         \"messages\": [
                    {
                      \"messageId\": \"MESSAGE-ID-123-xyz\",
                      \"from\": \"41793026700\",
                      \"fromB\":\"41793026701\",
                      \"destinationA\": \"41793026727\",
                      \"destinationB\": \"41793026731\",
                      \"text\": \"Test Voice message.\",
                      \"language\": \"en\",
                      \"anonymization\": false,
                      \"notifyUrl\": \"https://www.example.com/voice/clicktocall\",
                      \"notifyContentType\": \"application/json\",
                      \"maxDuration\": 60,
                      \"warningTime\": 5,
                      \"retry\": {
                        \"minPeriod\": 1,
                        \"maxPeriod\": 5,
                        \"maxCount\": 5
                        }
                      }  
                      ]
    
          }")
  .asString();
					
				
					var client = new RestClient("https://{base_url}/voice/ctc/1/send");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=");
request.AddParameter("application/json", 
          "{
            \"bulkId\": \"BULK-ID-123-xyz\",
            \"messages\": [
              {
                \"messageId\": \"MESSAGE-ID-123-xyz\",
                \"from\": \"41793026700\",
                \"destinationA\": \"41793026727\",
                \"fromB\":\"41793026701\",
                \"destinationB\": \"41793026731\",
                \"text\": \"Test Voice message.\",
                \"language\": \"en\",                               
                \"anonymization\": false,
                \"notifyUrl\": \"https://www.example.com/voice/clicktocall\",
                \"notifyContentType\": \"application/json\",
                \"maxDuration\": 60,
                \"warningTime\": 5,
                \"retry\": {
                  \"minPeriod\": 1,
                  \"maxPeriod\": 5,
                  \"maxCount\": 5
                  } 
              }
                ]
            }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
					
				
					var data = "{
  \"bulkId\": \"BULK-ID-123-xyz\",
  \"messages\": [
    {
      \"messageId\": \"MESSAGE-ID-123-xyz\",
      \"from\": \"41793026700\",
      \"destinationA\": \"41793026727\", 
      \"fromB\":\"41793026701\",    
      \"destinationB\": \"41793026731\",
      \"text\": \"Test Voice message.\",
      \"language\": \"en\",
      \"anonymization\": false,
      \"notifyUrl\": \"https://www.example.com/voice/clicktocall\",
      \"notifyContentType\": \"application/json\",
      \"maxDuration\": 60,
      \"warningTime\": 5,
      \"retry\": {
        \"minPeriod\": 1,
        \"maxPeriod\": 5,
        \"maxCount\": 5
        } 
      }
      ]
    }";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://{base_url}/voice/ctc/1/send");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
					
				

Response

					{
  "bulkId": "BULK-ID-123-xyz",
  "messages": [
    {
      "to": "41793026727",
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 26,
        "name": "PENDING_ACCEPTED",
        "description": "Message accepted, pending for delivery."
      },
      "messageId": "MESSAGE-ID-123-xyz"
    }
  ]
}
					
				

Response format

If successful, the response header HTTP status code will be 200 OK.

If you try to send the request without authorization, you will receive a 401 Unauthorized error.

Voice Response

Parameter Type Description
bulkId String The ID that uniquely identifies the request. Bulk ID will be received when a message is sent to more than one destination address.
messages VoiceResponseDetails Array of sent message objects, one object per message.

Voice Response Details

Parameter Type Description
to String The message destination address.
status Status Indicates whether the message has been sent successfully, not sent, delivered, not delivered, waiting for delivery, or other status.
messageId String The ID that uniquely identifies the sent message.

Status

Parameter Type Description
groupId int Status group ID.
groupName String Status group name.
id int Status ID.
name String Status name.
description String Human readable description of the status.