Sidebar Menu

UploadSoundFile

This method uploads a sound file. Our system accepts WAV files (PCM, u-law, A-law, or MS ADPCM). To use the sound file in a message, put tildes (~) around it and start it with a caret (^). Example: Hello ~^soundfile~, you are great. (The message would say "Hello," then play the sound file, and then say "you are great.")

Syntax

UploadSoundFile(FileBinary, SoundFileID, LicenseKey)

Request Parameters

Parameter Name Description Data Type Required Sample Value
FileBinary

The WAV file to upload. The minimum recommended sound quality is 16-bit mono PCM. The maximum file size allowed is 2 MB. Split your sound into multiple files if it is larger than 2 MB.

Array of Byte values True
SoundFileID

The ID to use for retrieving the sound file later on. The ID will be converted to lowercase.

String True greeting
LicenseKey

Your license key.

String True 00000000-0000-0000-0000-000000000000

Response

Returns: UploadSoundFileResponse object

Code Samples

You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.

/* https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl was added as a Service Reference and given the name WSDL */

using WSDL;

var client = new PhoneNotifySoapClient(PhoneNotifySoapClient.EndpointConfiguration.PhoneNotifySoap);
var fileBinary = File.ReadAllBytes(@"C:\Users\Public\hello.wav");
var soundFileId = "hello";
var response = await client.UploadSoundFileAsync(fileBinary, soundFileId, YOUR_LICENSE_KEY);

Console.WriteLine("Sound file was uploaded: " + response.UploadSoundFileResult.UploadSuccessful);
Console.WriteLine("File length: " + response.UploadSoundFileResult.UploadedLengthInSeconds + " seconds");
define("ALERTD_LICENSE_KEY", 'secretKeyHere');
define("ALERTD_CALLER_ID_NUMBER", '6175551212'); // caller id "from" number
define("ALERTD_CALLER_ID_NAME", 'Example.com');

$client = new SoapClient('https://ws.esendex.us/NotifyWS/PhoneNotify.asmx?wsdl');
print_r($client);

// Get contents of the file
$handle = fopen("mywavfile.wav", "r");
$contents = fread($handle, filesize("mywavfile.wav"));
fclose($handle);

// Set parameters
$params = array();
$params['LicenseKey'] = ALERTD_LICENSE_KEY;
$params['SoundFileID'] = 'test1';
$params['FileBinary'] = $contents;

// Make call
$result = $client->UploadSoundFile( $params );

// Print result
print_r($result);
import zeep

with open(r"C:\Users\Public\sound.ulaw", "rb") as file:
    file_binary = file.read()

client = zeep.Client(wsdl="https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl")
sound_file_id = "greeting"
license_key = "00000000-0000-0000-0000-000000000000"

result = client.service.UploadSoundFile(file_binary, sound_file_id, license_key)

print(result)
GET /NotifyWS/PhoneNotify.asmx/UploadSoundFile?FileBinary=string&FileBinary=string&SoundFileID=string&LicenseKey=string HTTP/1.1
Host: ws.esendex.us
POST /NotifyWS/PhoneNotify.asmx/UploadSoundFile HTTP/1.1
Host: ws.esendex.us
Content-Type: application/x-www-form-urlencoded
Content-Length: length

FileBinary=string&FileBinary=string&SoundFileID=string&LicenseKey=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<UploadFileResponse xmlns="https://ws.esendex.us/NotifyWS/">
  <UploadSuccessful>boolean</UploadSuccessful>
  <ErrorResponse>string</ErrorResponse>
  <UploadedLengthInSeconds>int</UploadedLengthInSeconds>
</UploadFileResponse>
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://ws.esendex.us/NotifyWS/UploadSoundFile"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UploadSoundFile xmlns="https://ws.esendex.us/NotifyWS/">
      <FileBinary>base64Binary</FileBinary>
      <SoundFileID>string</SoundFileID>
      <LicenseKey>string</LicenseKey>
    </UploadSoundFile>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UploadSoundFileResponse xmlns="https://ws.esendex.us/NotifyWS/">
      <UploadSoundFileResult>
        <UploadSuccessful>boolean</UploadSuccessful>
        <ErrorResponse>string</ErrorResponse>
        <UploadedLengthInSeconds>int</UploadedLengthInSeconds>
      </UploadSoundFileResult>
    </UploadSoundFileResponse>
  </soap:Body>
</soap:Envelope>
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <UploadSoundFile xmlns="https://ws.esendex.us/NotifyWS/">
      <FileBinary>base64Binary</FileBinary>
      <SoundFileID>string</SoundFileID>
      <LicenseKey>string</LicenseKey>
    </UploadSoundFile>
  </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <UploadSoundFileResponse xmlns="https://ws.esendex.us/NotifyWS/">
      <UploadSoundFileResult>
        <UploadSuccessful>boolean</UploadSuccessful>
        <ErrorResponse>string</ErrorResponse>
        <UploadedLengthInSeconds>int</UploadedLengthInSeconds>
      </UploadSoundFileResult>
    </UploadSoundFileResponse>
  </soap12:Body>
</soap12:Envelope>