{"_id":"55494b2bee219b0d001743c3","githubsync":"","version":{"_id":"55208137623ff50d009b2bef","__v":14,"project":"55208137623ff50d009b2bec","createdAt":"2015-04-05T00:26:31.564Z","releaseDate":"2015-04-05T00:26:31.563Z","categories":["55208138623ff50d009b2bf0","55494a226a82a10d00817ae5","55494ba7ee219b0d001743c8","55494bc1ee219b0d001743cc","56ead8c1df765617008bccaf","573a2073dd007d1700cf288f","579695b1f64c9f0e007cd76c","57969e3dfa1ff60e006a1274","579a4592fd9f3c0e008e4f4a","57ab9afe54fa780e006c5430","57b784f5b7ebd60e009cb4a6","58f686818193090f008cec76","59e79fbd4cf31900341d50c6","5b2436973fd93f0003dcf99d"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":6,"parentDoc":null,"project":"55208137623ff50d009b2bec","category":{"_id":"55494a226a82a10d00817ae5","project":"55208137623ff50d009b2bec","version":"55208137623ff50d009b2bef","__v":15,"pages":["55494ad0ee219b0d001743bb","55494b05f452670d00ec0c29","55494b11ee219b0d001743bf","55494b20ee219b0d001743c1","55494b2bee219b0d001743c3","55494b4a6a82a10d00817af5","55494b686a82a10d00817af9","5549651ccd09b317005f8f50","55497273cd09b317005f8f86","554977f0c634cf2d001250a7","55b970eab42b610d00c9b2e3","5696f3688560a60d00e2c216","5696f91c59a6692d003fad50","5696f92c24490c3700170a2d","5696f9700b09a41900b24422"],"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-05-05T22:54:26.925Z","from_sync":false,"order":2,"slug":"public-api","title":"Public API"},"editedParams":true,"editedParams2":true,"user":"55208129504fd6230022ae20","updates":["5584a1e6d57d770d00343ae5"],"next":{"pages":[],"description":""},"createdAt":"2015-05-05T22:58:51.133Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"curl 'https://www.sendsonar.com/api/v1/phone_numbers/available' \\\n  -X GET \\\n  -H 'X-Publishable-Key:XXXXXXXXXXXXXXXX' \\\n  -H \"Content-Type: application/json\"","language":"curl","name":""}]},"method":"get","results":{"codes":[{"name":"","code":"{\"available_number\":\"+14155558888\"}","language":"json","status":200}]},"settings":"","auth":"required","params":[{"_id":"554a8f5a6b448d0d00646c2c","ref":"","in":"query","required":true,"desc":"Your publishable key","default":"","type":"string","name":"X-Publishable-Key"}],"url":"/phone_numbers/available"},"isReference":true,"order":10,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Why Do I Need This?\",\n  \"body\": \"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.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<html>\\n  <meta content=\\\"text/html;charset=utf-8\\\" http-equiv=\\\"Content-Type\\\">\\n<meta content=\\\"utf-8\\\" http-equiv=\\\"encoding\\\">\\n  <head><title>Ok</title>\\n    <script>\\n      function getPhoneNumber() {\\n        xmlHttp = new XMLHttpRequest();\\n        xmlHttp.open( \\\"GET\\\", 'https://www.sendsonar.com/api/v1/phone_numbers/available', true );\\n        xmlHttp.setRequestHeader(\\\"X-Publishable-Key\\\",\\\"YOUR KEY HERE\\\");\\n        xmlHttp.setRequestHeader(\\\"Content-type\\\",\\\"application/json\\\");\\n        xmlHttp.onreadystatechange=function() {\\n          if (xmlHttp.readyState==4 && xmlHttp.status==200) {\\n            phone_no = JSON.parse(xmlHttp.responseText);\\n            pretty_phone = phone_no.available_number.replace(/(\\\\d{3})(\\\\d{3})(\\\\d{4})/, \\\"($1) $2-$3\\\");\\n\\n            // Might want to format the returning 10 digit number\\n            document.getElementById('phone').innerHTML = pretty_phone;\\n          }\\n        }\\n        xmlHttp.send();\\n      }\\n    </script>\\n  </head>\\n  <body onload=\\\"getPhoneNumber()\\\">\\n    <!-- Probably a good idea to have a default number incase the call fails -->\\n    <span id=\\\"phone\\\">XXX-YYY-ZZZZ</span>\\n  </body>\\n</html>\",\n      \"language\": \"html\",\n      \"gist\": \"f304d682afb5863f0609\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"available-phone-number","type":"endpoint","title":"Available Phone Number"}

getAvailable Phone Number


Definition

{{ api_url }}{{ page_api_url }}

Parameters

Query Params

X-Publishable-Key:
required
string
Your publishable key

Examples


Result Format


Documentation

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