

<!-- Home: no -->{"id":58142,"date":"2022-10-31T16:15:51","date_gmt":"2022-10-31T16:15:51","guid":{"rendered":"https:\/\/z2023devstaging.kinsta.cloud\/?page_id=58142"},"modified":"2022-12-14T08:20:28","modified_gmt":"2022-12-14T08:20:28","slug":"buy-phone-numbers","status":"publish","type":"page","link":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/","title":{"rendered":"Buy phone numbers via an API"},"content":{"rendered":"<p><strong>The Sonetel API allows you to instantly buy phone numbers in any country and city of choice.<\/strong><\/p>\n<p>Phone numbers purchased via the API receive a $1 discount on the monthly renewal fee. This means that phone numbers cost from $0.79 per month.<\/p>\n<div class=\"article-image-wrapper\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-50519\" src=\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg\" alt=\"\" width=\"1920\" height=\"1280\" srcset=\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg 1920w, https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash-300x200.jpg 300w, https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash-1024x683.jpg 1024w, https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash-768x512.jpg 768w, https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash-1536x1024.jpg 1536w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><\/div>\n<p>&nbsp;<\/p>\n<h2>How to buy a phone number via the API<\/h2>\n<p>This is how it works.<\/p>\n<ol>\n<li>Supported countries<br \/>\n<span style=\"color: #808080;\">Get a list of the<\/span> <a href=\"https:\/\/docs.sonetel.com\/docs\/sonetel-documentation\/9fef910e45bc9-inventory-phone-number-support-by-country\" target=\"_blank\" rel=\"noopener\">countries<\/a> <span style=\"color: #808080;\">where phone numbers can be purchased.<\/span><\/li>\n<li>See supported number types and number availability<br \/>\n<span style=\"color: #808080;\">Get a list of all <a href=\"https:\/\/docs.sonetel.com\/docs\/sonetel-documentation\/97b82ede83904-inventory-quantities-of-numbers-available-by-type-country\" target=\"_blank\" rel=\"noopener\">area codes and number types<\/a> in a specific country (city area codes, toll free, national, mobile numbers etc.) and the quantity of phone numbers that are available per city and prefix.<\/span><\/li>\n<li>See available numbers<br \/>\n<span style=\"color: #808080;\">Get a list of <a href=\"https:\/\/docs.sonetel.com\/docs\/sonetel-documentation\/1254c7ebc3ea7-inventory-available-numbers-in-a-country\" target=\"_blank\" rel=\"noopener\">phone numbers available for ordering<\/a>, of the specified type in the selected country.<\/span><\/li>\n<li>Buy a number<br \/>\n<span style=\"color: #808080;\"><a href=\"https:\/\/docs.sonetel.com\/docs\/sonetel-documentation\/72105ad25ba31-buy-a-number\" target=\"_blank\" rel=\"noopener\">Buy a number<\/a> and have it added to your account.<\/span><\/li>\n<\/ol>\n<p>In the next step you can configure the<a href=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/call-forwarding-api\/\" rel=\"noopener\"> call forwarding<\/a> of your new phone number.<\/p>\n<p>If your account is <a href=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/help\/help-topics\/team\/account-verification\/\" target=\"_blank\" rel=\"noopener\">verified<\/a>, and the phone number selected isn&#8217;t subject to specific <a href=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/help\/help-topics\/telephony\/phone-number-availability\/\" target=\"_blank\" rel=\"noopener\">activation restrictions<\/a> &#8211; the number will become activated instantly.<\/p>\n<p>&nbsp;<\/p>\n<h2>Buying a phone number with Python<\/h2>\n<p>A sample script for buying phone number with Python <a href=\"https:\/\/github.com\/Sonetel\/sonetel-api-docs\/blob\/develop\/sample-scripts\/buy-number\/Subscribe_Phone_Num.py\" target=\"_blank\" rel=\"noopener\">can be found here<\/a>. The script can be used after finding an available number for purchasing.<\/p>\n<p>The script starts by importing the necessary modules, and then defines the phone number to be purchased and the base URL of the Sonetel API.<\/p>\n<p>Next, it sets the access token for the API and decodes it to get the account ID of the user. It then constructs the request headers and sends an HTTP <code>POST<\/code> request to the <code>\/account\/{account_id}\/phonenumbersubscription<\/code> endpoint of the Sonetel API, passing the phone number and the access token in the request body and headers, respectively.<\/p>\n<p>If the request is successful, the response is printed to the console. Otherwise, an error is raised.<\/p>\n<p>To use the script, you will need to enter your <a href=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/token\/generate-token-with-python\/\">own access token<\/a> and the phone number you want to purchase. You can obtain the access token by following the instructions in the documentation at <a href=\"https:\/\/docs.sonetel.com\/\" target=\"_new\" rel=\"noopener\">https:\/\/docs.sonetel.com<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Buying a phone number with NodeJS<\/h2>\n<p>A sample script for buying phone number with NodeJS <a href=\"https:\/\/github.com\/Sonetel\/sonetel-api-docs\/blob\/develop\/sample-scripts\/buy-number\/Subscribe_Phone_Num.mjs\" target=\"_blank\" rel=\"noopener\">can be found here<\/a>. The script can be used after finding an available number for purchasing.<\/p>\n<p>The NodeJS module exports a function called <code>buyPhoneNumber<\/code>. This function can be used to purchase a phone number using the Sonetel API. The function accepts two arguments:<\/p>\n<ol>\n<li><span style=\"color: #808080;\"><code>accessToken<\/code>: The access token to authorize the request with Sonetel&#8217;s API.<\/span><\/li>\n<li><span style=\"color: #808080;\"><code>numToPurchase<\/code>: The phone number to purchase, in the E164 format (without the leading &#8220;+&#8221;).<\/span><\/li>\n<\/ol>\n<p>The function starts by checking that the <code>accessToken<\/code> and <code>numToPurchase<\/code> arguments are provided. If either is missing, an error is thrown. The access token is then decoded and the account ID is extracted.<\/p>\n<p>Next, the function constructs an HTTP <code>POST<\/code> request to the <code>\/account\/{account_id}\/phonenumbersubscription<\/code> endpoint of the Sonetel API, passing the phone number and access token in the request body and headers, respectively. The response is handled asynchronously and, if it is successful, the response data is logged to the console. Otherwise, an error is thrown.<\/p>\n<p>To use the function, you will need to import it into your script and call it with your own access token and the phone number you want to purchase. You can obtain the access token by<a href=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/token\/generate-token-with-nodejs\/\"> following the instructions here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased&#8230;<\/p>\n","protected":false},"author":3,"featured_media":50519,"parent":58131,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"templates\/help-subtopic-subsite.php","meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"description\" content=\"The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased via the API receive a $1 discount on\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Buy phone numbers via an API - Sonetel\" \/>\n<meta property=\"og:description\" content=\"The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased via the API receive a $1 discount on\" \/>\n<meta property=\"og:url\" content=\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/\" \/>\n<meta property=\"og:site_name\" content=\"Sonetel\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sonetel\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-14T08:20:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Sonetel\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#organization\",\"name\":\"Sonetel\",\"url\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/\",\"sameAs\":[\"https:\/\/www.facebook.com\/sonetel\",\"https:\/\/www.linkedin.com\/company\/sonetel\",\"https:\/\/twitter.com\/Sonetel\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2017\/10\/logo_horizontal.png\",\"contentUrl\":\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2017\/10\/logo_horizontal.png\",\"width\":137,\"height\":44,\"caption\":\"Sonetel\"},\"image\":{\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#website\",\"url\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/\",\"name\":\"Sonetel\",\"description\":\"A TELEPHONE SERVICE FOR GLOBAL ENTREPRENEURS\",\"publisher\":{\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg\",\"contentUrl\":\"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg\",\"width\":1920,\"height\":1280},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#webpage\",\"url\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/\",\"name\":\"Buy phone numbers via an API - Sonetel\",\"isPartOf\":{\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#primaryimage\"},\"datePublished\":\"2022-10-31T16:15:51+00:00\",\"dateModified\":\"2022-12-14T08:20:28+00:00\",\"description\":\"The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased via the API receive a $1 discount on\",\"breadcrumb\":{\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Developer\",\"item\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Help\",\"item\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Telephony API\",\"item\":\"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Buy phone numbers via an API\"}]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"description":"The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased via the API receive a $1 discount on","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/","og_locale":"en_US","og_type":"article","og_title":"Buy phone numbers via an API - Sonetel","og_description":"The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased via the API receive a $1 discount on","og_url":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/","og_site_name":"Sonetel","article_publisher":"https:\/\/www.facebook.com\/sonetel","article_modified_time":"2022-12-14T08:20:28+00:00","og_image":[{"width":1920,"height":1280,"url":"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_site":"@Sonetel","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#organization","name":"Sonetel","url":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/","sameAs":["https:\/\/www.facebook.com\/sonetel","https:\/\/www.linkedin.com\/company\/sonetel","https:\/\/twitter.com\/Sonetel"],"logo":{"@type":"ImageObject","@id":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#logo","inLanguage":"en-US","url":"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2017\/10\/logo_horizontal.png","contentUrl":"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2017\/10\/logo_horizontal.png","width":137,"height":44,"caption":"Sonetel"},"image":{"@id":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#logo"}},{"@type":"WebSite","@id":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#website","url":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/","name":"Sonetel","description":"A TELEPHONE SERVICE FOR GLOBAL ENTREPRENEURS","publisher":{"@id":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#primaryimage","inLanguage":"en-US","url":"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg","contentUrl":"https:\/\/z2023devstaging.kinsta.cloud\/wp-content\/uploads\/2022\/04\/reinhart-julian-MFjewnMDmrE-unsplash.jpg","width":1920,"height":1280},{"@type":"WebPage","@id":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#webpage","url":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/","name":"Buy phone numbers via an API - Sonetel","isPartOf":{"@id":"https:\/\/z2023devstaging.kinsta.cloud\/ar\/#website"},"primaryImageOfPage":{"@id":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#primaryimage"},"datePublished":"2022-10-31T16:15:51+00:00","dateModified":"2022-12-14T08:20:28+00:00","description":"The Sonetel API allows you to instantly buy phone numbers in any country and city of choice. Phone numbers purchased via the API receive a $1 discount on","breadcrumb":{"@id":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/buy-phone-numbers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/z2023devstaging.kinsta.cloud\/en\/"},{"@type":"ListItem","position":2,"name":"Developer","item":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/"},{"@type":"ListItem","position":3,"name":"Help","item":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/"},{"@type":"ListItem","position":4,"name":"Telephony API","item":"https:\/\/z2023devstaging.kinsta.cloud\/en\/developer\/help\/telephony-api\/"},{"@type":"ListItem","position":5,"name":"Buy phone numbers via an API"}]}]}},"_links":{"self":[{"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/pages\/58142"}],"collection":[{"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/comments?post=58142"}],"version-history":[{"count":10,"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/pages\/58142\/revisions"}],"predecessor-version":[{"id":58953,"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/pages\/58142\/revisions\/58953"}],"up":[{"embeddable":true,"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/pages\/58131"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/media\/50519"}],"wp:attachment":[{"href":"https:\/\/z2023devstaging.kinsta.cloud\/en\/wp-json\/wp\/v2\/media?parent=58142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}