Multiple voice messages

This method allows you to send multiple voice messages to one or more destination addresses.

Resource

https://api.infobip.com/tts/3/multi

Parameters

Property name Type Description
from string Numeric sender ID in E.164 format
to* array_string Array of message destination addresses. Destination address must be written in the international format (Example: 41793026727).
text string Text of the message that will be sent. Message text can be up to 1400 characters long.
language string (en) If the message is in text format, the language the message is written in must be defined for correct pronunciation. In the Languages section, you can find the list of supported languages. 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. 

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.

Request Example

					POST /tts/3/multi HTTP/1.1
Host: {base_url}
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
 
{ 
   "messages":[ 
      { 
         "from":"41793026700",
         "to":[ 
            "41793026727",
            "41793026731"
         ],
         "audioFileUrl": "https://www.example.com/media.mp3"
      },
      { 
         "from":"41793026800",
         "to": ["41793026785"],
         "text": "Hello world!",
         "language": "en",
         "voice": {
            "name": "Joanna",
            "gender": "female"
         }         
      }
   ]
}
					
				
					curl -X POST \
  -H "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{ 
   "messages":[ 
      { 
         "from":"41793026700",
         "to":[ 
            "41793026727",
            "41793026731"
         ],
         "audioFileUrl": "https://www.example.com/media.mp3"
      },
      { 
         "from":"98765",
         "to": ["41793026785"],
         "text": "Hello world!",
         "language": "en",
         "voice": {
            "name": "Joanna",
            "gender": "female"
         }
      }
   ]
}' "https://{base_url}/tts/3/multi"
					
				
					<?php
 
$curl = curl_init();
 
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://{base_url}/tts/3/multi",
  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
    \"messages\":[\n
      {\n
        \"from\":\"41793026700\",\n
        \"to\":[\n
          \"41793026727\",\n
          \"41793026731\"\n
        ],\n
        \"audioFileUrl\": \"https://www.example.com/media.mp3\"\n
      },\n
      {\n
        \"from\":\"41793026700\",\n
        \"to\": [\"41793026785\"],\n
        \"text\": \"Hello world!\",\n
        \"language\": \"en\",\n
        \"voice\": {\n
          \"name\": \"Joanna\",\n
          \"gender\": \"female\"\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}/tts/3/multi")
 
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
  \"messages\":[\n
    {\n
      \"from\":\"41793026700\",\n
      \"to\":[\n
        \"41793026727\",\n
        \"41793026731\"\n
      ],\n
      \"audioFileUrl\": \"https://www.example.com/media.mp3\"\n
    },\n
    {\n
      \"from\":\"41793026700\",\n
      \"to\": [\"41793026785\"],\n
      \"text\": \"Hello world!\",\n
      \"language\": \"en\",\n
      \"voice\": {\n
        \"name\": \"Joanna\",\n
        \"gender\": \"female\"\n
      }\n
    }\n
  ]\n
}"
 
response = http.request(request)
puts response.read_body
					
				
					import http.client
 
conn = http.client.HTTPSConnection("{base_url}")
 
payload = "{\n
  \"messages\":[\n
    {\n
      \"from\":\"41793026700\",\n
      \"to\":[\n
        \"41793026727\",\n
        \"41793026731\"\n
      ],\n
      \"audioFileUrl\": \"https://www.example.com/media.mp3\"\n
    },\n
    {\n
      \"from\":\"41793026700\",\n
      \"to\": [\"41793026785\"],\n
      \"text\": \"Hello world!\",\n
      \"language\": \"en\",\n
      \"voice\": {\n
        \"name\": \"Joanna\",\n
        \"gender\": \"female\"\n
      }\n
    }\n
 ]\n
}"
 
headers = {
    'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
    'content-type': "application/json",
    'accept': "application/json"
    }
 
conn.request("POST", "/tts/3/multi", payload, headers)
 
res = conn.getresponse()
data = res.read()
 
print(data.decode("utf-8"))
					
				
					HttpResponse<String> response = Unirest.post("https://{base_url}/tts/3/multi")
  .header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
  .header("content-type", "application/json")
  .header("accept", "application/json")
  .body("{\n
    \"messages\":[\n
      {\n
        \"from\":\"41793026700\",\n
        \"to\":[\n
          \"41793026727\",\n
          \"41793026731\"\n
        ],\n
        \"audioFileUrl\": \"https://www.example.com/media.mp3\"\n
      },\n
      {\n
        \"from\":\"41793026700\",\n
        \"to\": [\"41793026785\"],\n
        \"text\": \"Hello world!\",\n
        \"language\": \"en\",\n
        \"voice\": {\n
          \"name\": \"Joanna\",\n
          \"gender\": \"female\"\n
        }\n
      }\n
    ]\n
  }")
  .asString();
					
				
					var client = new RestClient("https://{base_url}/tts/3/multi");
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", "{\n
  \"messages\":[\n
    {\n
      \"from\":\"41793026700\",\n
      \"to\":[\n
        \"41793026727\",\n
        \"41793026731\"\n
      ],\n
      \"audioFileUrl\": \"https://www.example.com/media.mp3\"\n
    },\n
    {\n
      \"from\":\"41793026700\",\n
      \"to\": [\"41793026785\"],\n
      \"text\": \"Hello world!\",\n
      \"language\": \"en\",\n
      \"voice\": {\n
        \"name\": \"Joanna\",\n
        \"gender\": \"female\"\n
      }\n
    }\n
  ]\n
}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
					
				
					var data = JSON.stringify({
  "messages": [
    {
      "from": " 41793026700",
      "to": [
        "41793026727",
        "41793026731"
      ],
      "audioFileUrl": "https://www.example.com/media.mp3"
    },
    {
      "from": "41793026700",
      "to": [
        "41793026785"
      ],
      "text": "Hello world!",
      "language": "en",
      "voice": {
        "name": "Joanna",
        "gender": "female"
      }
    }
  ]
});
 
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}/tts/3/multi");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
 
xhr.send(data);
					
				

Response

					{
  "bulkId":"5028e2d42f19-42f1-4656-351e-a42c191e5fd2",
  "messages": [
    {
      "to": "41793026727",
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 26,
        "name": "PENDING_ACCEPTED",
        "description": "Message accepted, pending for delivery."
      },
      "messageId":"4242f196ba50-a356-2f91-831c4aa55f351ed2"
    },
    {
      "to": "41793026731",
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 26,
        "name": "PENDING_ACCEPTED",
        "description": "Message accepted, pending for delivery."
      },
      "messageId":"5f35f896ba50-a356-43a4-91cd81b85f8c689"
    },
    {
      "to": "41793026785",
      "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

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

VoiceResponseDetails

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

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.