Launch outbound IVR
This method allows you to start an outbound IVR toward a multiple destinations.
Resource
https://api.infobip.com/voice/ivr/1/messages
Parameters
Property name | Type | Description |
---|---|---|
bulkId | string | The ID which uniquely identifies the request. |
from | string (41793026700) | 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: 41793026727). |
scenarioId* | string | Scenario key. |
messageId | string | The ID that uniquely identifies the message sent. |
parameters | object | The parameters that should be passed to the scenario on execution. |
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 IVR flow (IVR will not to be sent immediately, but at scheduled time). |
callbackData | string | Additional client's data that will be sent on the notifyUrl. The maximum value is 200 characters. |
retry | object | Used to define if the delivery of the IVR 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. IVR delivery will be retried until the successful delivery or 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 flow again. |
maxPeriod | int | Defines the maximum waiting time (in minutes) after the previous failed attempt to try to deliver the flow 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 if scheduling is used) and subsequent messages will be sent respecting defined speed. For example, if sending speed is defined as 10 messages per hour, messages will be sent every 6 minutes. If this parameter is defined, validity period 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. |
Request Example
POST /voice/ivr/1/messages HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"parameters": {
"foo": "bar"
},
"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,
"retry": {
"minPeriod":1,
"maxPeriod": 5,
"maxCount":5
}
}
]
}
curl -X POST \
'https://{base_url}/voice/ivr/1/messages' \
-H 'Accept: application/json' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-H 'Content-Type: application/json' \
-d '{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"parameters": {
"foo": "bar"
},
"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,
"retry": {
"minPeriod": 1,
"maxPeriod": 5,
"maxCount": 5
}
}
]
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://{base_url}/voice/ivr/1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"bulkId\": \"BULK-ID-123-xyz\",\n \"messages\": [\n {\n \"scenarioId\": \"6298AA7707903A4ED680B436929681AD\",\n \"from\": \"41793026700\",\n \"destinations\": [\n {\n \"to\": \"41793026727\"\n },\n {\n \"to\": \"41793026731\"\n }\n ],\n \"parameters\": {\n \"foo\": \"bar\"\n },\n \"notifyUrl\": \"https://www.example.com/voice/advanced\",\n \"notifyContentType\": \"application/json\",\n \"callbackData\": \"DLR callback data\",\n \"validityPeriod\": 720,\n \"sendAt\": \"2016-07-07T17:00:00.000+01:00\",\n \"record\": false,\n \"retry\": {\n \"minPeriod\": 1,\n \"maxPeriod\": 5,\n \"maxCount\": 5\n }\n }\n ]\n}",
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;
}
require 'uri'
require 'net/http'
url = URI("https://{base_url}/voice/ivr/1/messages")
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 = "{\n \"bulkId\": \"BULK-ID-123-xyz\",\n \"messages\": [\n {\n \"scenarioId\": \"6298AA7707903A4ED680B436929681AD\",\n \"from\": \"41793026700\",\n \"destinations\": [\n {\n \"to\": \"41793026727\"\n },\n {\n \"to\": \"41793026731\"\n }\n ],\n \"parameters\": {\n \"foo\": \"bar\"\n },\n \"notifyUrl\": \"https://www.example.com/voice/advanced\",\n \"notifyContentType\": \"application/json\",\n \"callbackData\": \"DLR callback data\",\n \"validityPeriod\": 720,\n \"sendAt\": \"2016-07-07T17:00:00.000+01:00\",\n \"record\": false,\n \"retry\": {\n \"minPeriod\": 1,\n \"maxPeriod\": 5,\n \"maxCount\": 5\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("{base_url}")
payload = "{\n \"bulkId\": \"BULK-ID-123-xyz\",\n \"messages\": [\n {\n \"scenarioId\": \"6298AA7707903A4ED680B436929681AD\",\n \"from\": \"41793026700\",\n \"destinations\": [\n {\n \"to\": \"41793026727\"\n },\n {\n \"to\": \"41793026731\"\n }\n ],\n \"parameters\": {\n \"foo\": \"bar\"\n },\n \"notifyUrl\": \"https://www.example.com/voice/advanced\",\n \"notifyContentType\": \"application/json\",\n \"callbackData\": \"DLR callback data\",\n \"validityPeriod\": 720,\n \"sendAt\": \"2016-07-07T17:00:00.000+01:00\",\n \"record\": false,\n \"retry\": {\n \"minPeriod\": 1,\n \"maxPeriod\": 5,\n \"maxCount\": 5\n }\n }\n ]\n}"
headers = {
'Authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "voice,ivr,1,messages", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.post("https://{base_url}/voice/ivr/1/messages")
.header("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.body("{\n \"bulkId\": \"BULK-ID-123-xyz\",\n \"messages\": [\n {\n \"scenarioId\": \"6298AA7707903A4ED680B436929681AD\",\n \"from\": \"41793026700\",\n \"destinations\": [\n {\n \"to\": \"41793026727\"\n },\n {\n \"to\": \"41793026731\"\n }\n ],\n \"parameters\": {\n \"foo\": \"bar\"\n },\n \"notifyUrl\": \"https://www.example.com/voice/advanced\",\n \"notifyContentType\": \"application/json\",\n \"callbackData\": \"DLR callback data\",\n \"validityPeriod\": 720,\n \"sendAt\": \"2016-07-07T17:00:00.000+01:00\",\n \"record\": false,\n \"retry\": {\n \"minPeriod\": 1,\n \"maxPeriod\": 5,\n \"maxCount\": 5\n }\n }\n ]\n}")
.asString();
var client = new RestClient("https://{base_url}/voice/ivr/1/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddParameter("undefined", "{\n \"bulkId\": \"BULK-ID-123-xyz\",\n \"messages\": [\n {\n \"scenarioId\": \"6298AA7707903A4ED680B436929681AD\",\n \"from\": \"41793026700\",\n \"destinations\": [\n {\n \"to\": \"41793026727\"\n },\n {\n \"to\": \"41793026731\"\n }\n ],\n \"parameters\": {\n \"foo\": \"bar\"\n },\n \"notifyUrl\": \"https://www.example.com/voice/advanced\",\n \"notifyContentType\": \"application/json\",\n \"callbackData\": \"DLR callback data\",\n \"validityPeriod\": 720,\n \"sendAt\": \"2016-07-07T17:00:00.000+01:00\",\n \"record\": false,\n \"retry\": {\n \"minPeriod\": 1,\n \"maxPeriod\": 5,\n \"maxCount\": 5\n }\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var data = JSON.stringify({
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"parameters": {
"foo": "bar"
},
"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,
"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/ivr/1/messages");
xhr.setRequestHeader("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send(data);
Response
{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"to": "385993061678",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 26,
"name": "PENDING_ACCEPTED",
"description": "Message accepted, pending for delivery."
},
"messageId": "fda25a85-22fe-43e4-ad70-acb01bbd919b"
}
]
}
Response format
If successful, the response header HTTP status code will be 200 OK
and the IVR flow will be sent.
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. |