Resource
https://vapi.smsgatewayhub.com/tts/3/advanced
Parameters
Property Name |
Type |
Description |
bulkId |
string |
The ID which uniquely identifies the request. |
from |
string-919999999999 |
Numeric sender ID length should be between 3 and 14 characters. |
to* |
array_string |
Array of message destination addresses. Destination address must be in the international format (Example: 919999999999). |
messageId |
string |
The ID that uniquely identifies the message sent. |
text |
string |
Text of the message that will be sent. Pause between words is possible. Message text can be up to 1400 characters long. |
language |
string (en) |
If the message is in text format, language in which the message is written must be defined for correct pronunciation. Below, in the Languages section, you can find the list of languages that we support. If not set, default language is English [en].
|
voice |
object |
Used to define voice in which text would be synthesized. It has two parameters: name and gender. When only name is provided, then that exact voice with that name will be used to synthesize text. If only gender is provided, then text is synthesized with first voice in given gender. Gender can be male or female. If voice is not set, then default voice is used. |
audioFileUrl |
string |
Besides the text format of the message, audio recording (format like: wav, mp3, ogg, etc.) can also be delivered as a voice message to the recipient. 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. |
speechRate |
double (1) |
The reproduction speed of speech in the resulting message. Effective only when using text. Supported range is from 0.5 (slow down speech) to 2 (speed up speech). Values less than 0.5 will be replaced with 0.5, and values higher than 2 will be replaced with 2. |
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. |
validityPeriod |
int |
The message validity period shown in minutes. When the period expires, it will not be allowed for the message to be sent. A validity period longer than 48h is not supported (in this case, it will be automatically set to 48h). |
sendAt |
datetime |
Used for scheduled Voice messages (message not to be sent immediately, but at scheduled time). |
record |
boolean |
Record the call and expose it to client as URL inside the delivery report. Can be true or false. |
repeatDtmf |
string |
Response (DTMF) code which enables repeating message if a subscriber enters it. |
maxDtmf |
int int(0) |
Defines the max number of dtmf codes entered by end user that would be received. |
ringTimeout |
int (45) |
The duration of the call prior to answer shown in seconds, unless there are no operator limitations. |
dtmfTimeout |
int (10) |
The waiting period for end user to enter dtmf digits. |
callTimeout |
int |
Total call period shown in seconds. |
callTransfers |
array_object |
Possible call transfer scenario defined as JSON object. See example below |
processKey |
string |
Key that uniquely identifies Conversion tracking process. |
callbackData |
string |
Additional client's data that will be sent on the notifyUrl. The maximum value is 200 characters. |
pause |
int (0) |
Indicating period of time in seconds between end user answering the call and message starting to be played. Minimal value is 0 and maximum value is 10 seconds. |
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. |
sendingSpeed |
object |
Sending rate defined in number of messages sent per second, minute, hour or day. First message will be sent immediately (or at sendAt time if scheduling is used) and subsequent messages will be sent respecting defined speed. For example, if sendingSpeed is defined as 10 messages per hour, messages will be sent every 6 minutes. If this parameter is defined, validityPeriod is ignored. |
speed |
int |
Defines the number of messages that will be sent per specified time unit. |
timeUnit |
string |
Defines time unit used for calculating sending speed. Possible values: second, minute, hour and day. |
machineDetection |
string |
Used for enabling detection of answering machine after the call has been answered. It can be set to "hangup" or "continue". When set to "hangup", if a machine is detected call is hung up. When set to "continue", if a machine is detected, then voice message starts playing into voice mail after the answering message is finished with its greeting.
If machineDetection is used, there is a minimum of 4 seconds detection time, which can result in delay of playing the message.
Answering machine detection is additionally charged. For more information please contact your account manager. |
Request Example
JSON :
POST /tts/3/advanced HTTP/1.1
Host: vapi.smsgatewayhub.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"from": "919999999999",
"destinations": [
{
"to": "916666666666",
"messageId": "MESSAGE-ID-123-xyz"
},
{
"to": "916666666666"
}
],
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
},
"speechRate": 1,
"notifyUrl": "https://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"callbackData":"DLR callback data",
"validityPeriod": 720,
"sendAt": "2016-07-07T17:00:00.000+01:00",
"record": false,
"repeatDtmf": "123#",
"maxDtmf":1,
"ringTimeout": 45,
"dtmfTimeout": 10,
"callTimeout": 130,
"pause": 3,
"retry": {
"minPeriod":1,
"maxPeriod": 5,
"maxCount":5
},
"machineDetection": "continue"
},
{
"from": "919999999999",
"destinations": [
{
"to": "916666666666"
}
],
"text": "A long time ago, in a galaxy far.",
"sendAt": "2016-07-07T18:00:00.000+01:00"
}
],
"tracking":{
"track": "VOICE",
"type": "MY_CAMPAIGN"
}
}
cURL :
curl -X POST \
-H "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"bulkId":"BULK-ID-123-xyz",
"messages":[
{
"from":"919999999999",
"destinations":[
{
"to":"916666666666",
"messageId":"MESSAGE-ID-123-xyz"
},
{
"to":"916666666666"
}
],
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
},
"speechRate":1,
"notifyUrl":"https://www.example.com/voice/advanced",
"notifyContentType":"application/json",
"validityPeriod": 720,
"sendAt":"2016-07-07T17:00:00.000+01:00",
"record": false,
"repeatDtmf": "123#",
"maxDtmf": 1
"ringTimeout": 45,
"dtmfTimeout": 10,
"callTimeout": 130,
"pause": 3,
"retry": {
"minPeriod":1,
"maxPeriod": 5,
"maxCount":5
},
"machineDetection": "continue"
},
{
"from":"919999999999",
"destinations":[
{
"to":"916666666666"
}
],
"text":"A long time ago, in a galaxy far.",
"sendAt":"2016-07-07T18:00:00.000+01:00"
}
]
}' "https://vapi.smsgatewayhub.com/tts/3/advanced"
PHP :
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://vapi.smsgatewayhub.com/tts/3/advanced",
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\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"voice\": {
\"name\": \"Joanna\",
\"gender\": \"female\"
},
\"speechRate\": 1,
\"notifyUrl\": \"https://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": 1,
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"machineDetection\": \"continue\"
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"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;
}
Ruby :
require 'uri'
require 'net/http'
url = URI("https://vapi.smsgatewayhub.com/tts/3/advanced")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["content-type"] = 'application/json'
request["accept"] = 'application/json'
request.body = "{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"voice\": {
\"name\": \"Joanna\",
\"gender\": \"female\"
},
\"speechRate\": 1,
\"notifyUrl\": \"https://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": 1,
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"machineDetection\": \"continue\"
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}",
response = http.request(request)
puts response.read_body
Python :
import http.client
conn = http.client.HTTPSConnection("vapi.smsgatewayhub.com")
payload = "{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"voice\": {
\"name\": \"Joanna\",
\"gender\": \"female\"
},
\"speechRate\": 1,
\"notifyUrl\": \"https://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": 1,
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"machineDetection\": \"continue\"
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}"
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/tts/3/advanced", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Java :
HttpResponse<String> response = Unirest.post("https://vapi.smsgatewayhub.com/tts/3/advanced")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("content-type", "application/json")
.header("accept", "application/json")
.body("{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"voice\": {
\"name\": \"Joanna\",
\"gender\": \"female\"
},
\"speechRate\": 1,
\"notifyUrl\": \"https://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": 1,
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"machineDetection\": \"continue\"
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}")
.asString();
C# :
var client = new RestClient("https://vapi.smsgatewayhub.com/tts/3/advanced");
var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddParameter("application/json",
"{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"voice\": {
\"name\": \"Joanna\",
\"gender\": \"female\"
},
\"speechRate\": 1,
\"notifyUrl\": \"https://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": 1,
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"machineDetection\": \"continue\"
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
JavaScript :
var data = JSON.stringify({
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"from": "919999999999",
"destinations": [
{
"to": "916666666666",
"messageId": "MESSAGE-ID-123-xyz"
},
{
"to": "916666666666"
}
],
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
},
"speechRate": 1,
"notifyUrl": "https://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"validityPeriod": 720,
"sendAt": "2016-07-07T17:00:00.000+01:00",
"record": false,
"repeatDtmf": "123#",
"repeatDtmf": 1,
"ringTimeout": 45,
"dtmfTimeout": 10,
"callTimeout": 130,
"pause": 3,
"retry": {
"minPeriod":1,
"maxPeriod": 5,
"maxCount":5
},
"machineDetection": "continue"
},
{
"from": "919999999999",
"destinations": [
{
"to": "916666666666"
}
],
"text": "A long time ago, in a galaxy far.",
"sendAt": "2016-07-07T18:00:00.000+01:00"
}
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://vapi.smsgatewayhub.com/tts/3/advanced");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
Response
200 OK
{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"to": "916666666666",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId": "MESSAGE-ID-123-xyz"
},
{
"to": "916666666666",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId":"9304a5a3ab19-1ca1-be74-76ad87651ed25f35"
},
{
"to": "916666666666",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId":"5f35f87a2f19-a141-43a4-91cd81b85f8c689"
}
]
}
Response format
If successful, the response header HTTP status code will be 200 OK and the message will be sent.
If you try to send the message without authorization, you will receive a 401 Unauthorized error.
VoiceResponse
Property Name |
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 every message. |
VoiceResponseDetails
Property Name |
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 any other possible 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. |
Pause between words
Adding pauses between the words and extending the duration of the voice message is possible by using the comma character ",".
For example, if you want to have a 3 second pause after each word, then the text parameter should look like this "one,,,,,,two,,,,,,three,,,,,,". Each coma creates a pause of 0,5 seconds.
Ring timeout limitations
There are no limitations on the Voice platform regarding this value, however, most of the operators have their own ring timeout limitations and it is advisable to keep the ringTimeout value up to 45s.
Call Transfers
Using call transfer, you can send an interactive message to your subscribers, providing them the opportunity to respond by pressing their phone keys. When your subscriber chooses a number call transfer will redirect a call to the set number. The Field is JSON formatted.
Call transfer for any DTMF
[
{
"if": "anyDtmf",
"transferTo": "919999999999",
"callTransferMaxDuration": 10
}
]
Call transfer for specific DTMF
[
{
"if": "dtmf",
"equals": "1",
"transferTo": "919999999999"
},
{
"if": "dtmf",
"equals": "2",
"transferTo": "919999999999"
}
]
Request example
JSON :
POST /tts/3/advanced HTTP/1.1
Host: vapi.smsgatewayhub.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"bulkId":"BULK-ID-123-xyz",
"messages":[
{
"from":"919999999999",
"destinations":[
{
"to":"916666666666",
"messageId":"MESSAGE-ID-123-xyz"
},
{
"to":"916666666666"
}
],
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
},
"speechRate":1,
"notifyUrl":"http://www.example.com/voice/advanced",
"notifyContentType":"application/json",
"validityPeriod": 720,
"sendAt":"2016-07-07T17:00:00.000+01:00",
"record": false,
"repeatDtmf": "123#",
"maxDtmf":1,
"ringTimeout": 45,
"dtmfTimeout": 10,
"callTimeout": 130,
"pause":3,
"retry": {
"minPeriod":1,
"maxPeriod": 5,
"maxCount":5
},
"callTransfers": [
{
"if": "dtmf",
"equals": "1",
"transferTo": "916666666666"
},
{
"if": "dtmf",
"equals": "2",
"transferTo": "916666666666"
}
]
},
{
"from":"919999999999",
"destinations":[
{
"to":"916666666666"
}
],
"text":"A long time ago, in a galaxy far.",
"sendAt":"2016-07-07T18:00:00.000+01:00"
}
]
}
cURL :
curl -X POST \
-H "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"bulkId":"BULK-ID-123-xyz",
"messages":[
{
"from":"919999999999",
"destinations":[
{
"to":"916666666666",
"messageId":"MESSAGE-ID-123-xyz"
},
{
"to":"916666666666"
}
],
"text": "Test Voice message.",
"language": "en",
"speechRate":1,
"notifyUrl":"http://www.example.com/voice/advanced",
"notifyContentType":"application/json",
"validityPeriod": 720,
"sendAt":"2016-07-07T17:00:00.000+01:00",
"record": false,
"repeatDtmf": "123#",
"maxDtmf":1,
"ringTimeout": 45,
"dtmfTimeout": 10,
"callTimeout": 130,
"pause": 3,
"retry": {
"minPeriod":1,
"maxPeriod": 5,
"maxCount":5
},
"callTransfers": [
{
"if": "dtmf",
"equals": "1",
"transferTo": "916666666666"
},
{
"if": "dtmf",
"equals": "2",
"transferTo": "916666666666"
}
]
},
{
"from":"919999999999",
"destinations":[
{
"to":"916666666666"
}
],
"text":"A long time ago, in a galaxy far.",
"sendAt":"2016-07-07T18:00:00.000+01:00"
}
]
}' "http://vapi.smsgatewayhub.com/tts/3/advanced"
PHP :
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://vapi.smsgatewayhub.com/tts/3/advanced",
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\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"speechRate\": 1,
\"notifyUrl\": \"http://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": \"1\",
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"callTransfers\": [
{
\"if\": \"dtmf\",
\"equals\": \"1\",
\"transferTo\": \"916666666666\"
},
{
\"if\": \"dtmf\",
\"equals\": \"2\",
\"transferTo\": \"916666666666\"
}
]
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"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;
}
Ruby :
require 'uri'
require 'net/http'
url = URI("http://vapi.smsgatewayhub.com/tts/3/advanced")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["content-type"] = 'application/json'
request["accept"] = 'application/json'
request.body = "{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"speechRate\": 1,
\"notifyUrl\": \"http://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": \"1\",
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"callTransfers\": [
{
\"if\": \"dtmf\",
\"equals\": \"1\",
\"transferTo\": \"916666666666\"
},
{
\"if\": \"dtmf\",
\"equals\": \"2\",
\"transferTo\": \"916666666666\"
}
]
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}"
response = http.request(request)
puts response.read_body
Python :
import http.client
conn = http.client.HTTPConnection("vapi.smsgatewayhub.com")
payload = "{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"speechRate\": 1,
\"notifyUrl\": \"http://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": \"1\",
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"callTransfers\": [
{
\"if\": \"dtmf\",
\"equals\": \"1\",
\"transferTo\": \"916666666666\"
},
{
\"if\": \"dtmf\",
\"equals\": \"2\",
\"transferTo\": \"916666666666\"
}
]
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}"
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/tts/3/advanced", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Java :
HttpResponse<String> response = Unirest.post("http://vapi.smsgatewayhub.com/tts/3/advanced")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("content-type", "application/json")
.header("accept", "application/json")
.body("{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"speechRate\": 1,
\"notifyUrl\": \"http://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": \"1\",
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"callTransfers\": [
{
\"if\": \"dtmf\",
\"equals\": \"1\",
\"transferTo\": \"916666666666\"
},
{
\"if\": \"dtmf\",
\"equals\": \"2\",
\"transferTo\": \"916666666666\"
}
]
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}")
.asString();
C# :
var client = new RestClient("http://vapi.smsgatewayhub.com/tts/3/advanced");
var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddParameter("application/json",
"{
\"bulkId\": \"BULK-ID-123-xyz\",
\"messages\": [
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\",
\"messageId\": \"MESSAGE-ID-123-xyz\"
},
{
\"to\": \"916666666666\"
}
],
\"text\": \"Test Voice message.\",
\"language\": \"en\",
\"speechRate\": 1,
\"notifyUrl\": \"http://www.example.com/voice/advanced\",
\"notifyContentType\": \"application/json\",
\"validityPeriod\": 720,
\"sendAt\": \"2016-07-07T17:00:00.000+01:00\",
\"record\": false,
\"repeatDtmf\": \"123#\",
\"maxDtmf\": \"1\",
\"ringTimeout\": 45,
\"dtmfTimeout\": 10,
\"callTimeout\": 130,
\"pause\": 3,
\"retry\": {
\"minPeriod\": 1,
\"maxPeriod\": 5,
\"maxCount\": 5
},
\"callTransfers\": [
{
\"if\": \"dtmf\",
\"equals\": \"1\",
\"transferTo\": \"916666666666\"
},
{
\"if\": \"dtmf\",
\"equals\": \"2\",
\"transferTo\": \"916666666666\"
}
]
},
{
\"from\": \"919999999999\",
\"destinations\": [
{
\"to\": \"916666666666\"
}
],
\"text\": \"A long time ago, in a galaxy far.\",
\"sendAt\": \"2016-07-07T18:00:00.000+01:00\"
}
]
}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
JavaScript :
var data = JSON.stringify({
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"from": "919999999999",
"destinations": [
{
"to": "916666666666",
"messageId": "MESSAGE-ID-123-xyz"
},
{
"to": "916666666666"
}
],
"text": "Test Voice message.",
"language": "en",
"speechRate": 1,
"notifyUrl": "http://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"validityPeriod": 720,
"sendAt": "2016-07-07T17:00:00.000+01:00",
"record": false,
"repeatDtmf": "123#",
"maxDtmf": "1",
"ringTimeout": 45,
"dtmfTimeout": 10,
"callTimeout": 130,
"pause": 3,
"callTransfers": [
{
"if": "dtmf",
"equals": "1",
"transferTo": "916666666666"
},
{
"if": "dtmf",
"equals": "2",
"transferTo": "916666666666"
}
]
},
{
"from": "919999999999",
"destinations": [
{
"to": "916666666666"
}
],
"text": "A long time ago, in a galaxy far.",
"sendAt": "2016-07-07T18:00:00.000+01:00"
}
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://vapi.smsgatewayhub.com/tts/3/advanced");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
API response
JSON
{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"to": "916666666666",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId": "MESSAGE-ID-123-xyz"
},
{
"to": "916666666666",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId":"9304a5a3ab19-1ca1-be74-76ad87651ed25f35"
},
{
"to": "916666666666",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId":"f0401b7b-5c44-4a62-8a1b-61ec26101ff0"
}
]
}