📘

Why Do I Need This?

The Available Phone Number API endpoint is needed because depending on how many customers you have, we may purchase multiple numbers for your company. We always want to try to use the phone number with the least number of associated customers to optimize for deliverability.

<html> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta content="utf-8" http-equiv="encoding"> <head><title>Ok</title> <script> function getPhoneNumber() { xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", 'https://www.sendsonar.com/api/v1/phone_numbers/available', true ); xmlHttp.setRequestHeader("X-Publishable-Key","YOUR KEY HERE"); xmlHttp.setRequestHeader("Content-type","application/json"); xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState==4 && xmlHttp.status==200) { phone_no = JSON.parse(xmlHttp.responseText); pretty_phone = phone_no.available_number.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3"); // Might want to format the returning 10 digit number document.getElementById('phone').innerHTML = pretty_phone; } } xmlHttp.send(); } </script> </head> <body onload="getPhoneNumber()"> <!-- Probably a good idea to have a default number incase the call fails --> <span id="phone">XXX-YYY-ZZZZ</span> </body> </html>
Headers
string
required

Your Sonar account's publishable key

Responses

Language
Credentials
Request
Choose an example:
application/json