Code Snippet Example

Send and receive messages directly from your web application with the Voice API.

var myHeaders = new Headers();
myHeaders.append("XApiKey", "MY API KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "from": "sender Id",
    "body": "My message",
    "to": "country code + phone number"
});

var requestOptions = {
    method: 'POST',
    headers: myHeaders,
    body: raw,
    redirect: 'follow'
};

fetch("https://ypapikey-test.azurewebsites.net/Voice", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

Last updated