Overview
All phone numbers on the IntelePeer network can be used to send and receive SMS messages. You can enable SMS over your phone number by:
- Configuring a number through the IntelePeer Customer Portal
- Configuring a number through the Atmosphere® API
This page discusses SMS enablement via API for long codes only. Short codes can be ordered by contacting IntelePeer directly. Learn more about number enablement through the IntelePeer Customer Portal in the Quick Start Guide.
Configuring Numbers via API
Configuring a phone number through the Atmosphere® API requires two steps:
- Explicitly enable SMS for the phone number
- Create and set the webhook for processing of inbound SMS messages
Checking Number Configuration via API
You can check the current configuration of a number through the Atmosphere® API:
- Get the SMS enablement status of a phone number
- Get the current webhook for a phone number
Enabling SMS for a single Phone Number via API
URI
POST to https://api.intelepeer.com/sms/v1/{tn}/provision
{tn} is the phone number to be provisioned in E.164 format.
For example, you would enable +17208675309 for sending/receiving SMS messages by POST-ing to the URL
https://api.intelepeer.com/sms/v1/+17208675309/provision
Parameters
None, however this API method requires an Authorization token. Learn more about the Authorization token in Atmosphere® API Authentication.
Response Codes
Response Code | Description |
---|---|
202 | The provisioning request has been accepted and is pending completion. |
400 | The reason for the error is contained within the response. |
401 | The reason for the error is contained within the response. |
409 | Provisioning (or deprovisioning) of the number is in progress. |
Behavior
Enabling of numbers for SMS typically happens within minutes, however there are some cases where a number may take longer to enable:
- Toll free numbers for which IntelePeer is not the resporg
- DIDs and Toll Free Numbers that are already being used for SMS within another service
Example Code
[tabby title=”C#”]
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IntelePeerSMSExampleClient.provisioning { class ProvisionTN { public void run() { string TN = INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; string url = "https://api.intelepeer.com/sms/v1/" + TN + "/provision"; string AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; System.Net.WebRequest httpWebRequest = System.Net.WebRequest.Create(url); httpWebRequest.Method = "POST"; //Add Header httpWebRequest.ContentType = "application/json"; httpWebRequest.Headers.Add("Authorization", "Bearer " + AUTH_TOKEN); try { //Submit Request and Read Response System.Net.WebResponse httpResponse = httpWebRequest.GetResponse(); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream())) { string result = streamReader.ReadToEnd(); System.Console.Write(result); } } catch (System.Net.WebException webException) { string response = webException.Message; } catch (Exception exception) { string response = exception.Message; } finally { //do something else } } } }
[tabby title=”Java”]
package main.java.tnActions.provisioning; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; public class ProvisionTn { public static void main(String... args) throws Exception { final String TN = "INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; final String url = "https://api.intelepeer.com/sms/v1/" + TN + "/provision"; final String AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; HttpClient httpclient = HttpClientBuilder.create().build(); HttpPost httpPost = new HttpPost(url); // add header httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN); // execute POST HttpResponse response = httpclient.execute(httpPost); System.out.println("\nSending 'POST' request to URL : " + url); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println(result.toString()); } }
[tabby title=”Node.js”]
const request = require("request"); /////////////////////////////////////////////////////////////////////////////// /// update these accordingly /// /////////////////////////////////////////////////////////////////////////////// let authtoken = 'INSERT_AUTH_TOKEN_HERE' let tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' /////////////////////////////////////////////////////////////////////////////// /// leave these alone /// /////////////////////////////////////////////////////////////////////////////// let url = "https://api.intelepeer.com/sms/v1/"+ tn +"/provision" let hdrs = { 'Content-Type': "application/json", 'Authorization': "Bearer " + authtoken } /////////////////////////////////////////////////////////////////////////////// /// execute the task and parse results /// /////////////////////////////////////////////////////////////////////////////// request.post({ url: url, headers: hdrs, form: {} }, (error, response, body) => { result = JSON.parse(body); console.log(result.text); });
[tabby title=”PHP”]
<?php require '../../vendor/autoload.php'; use GuzzleHttp\Client; ############################################################################### ### update these accordingly ### ############################################################################### $authtoken = 'INSERT_AUTH_TOKEN_HERE'; $tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT'; ############################################################################### ### leave these alone ### ############################################################################### $url = "https://api.intelepeer.com/sms/v1/$tn/webhook"; $hdrs = ['Content-Type' => "application/json", 'Authorization' => 'Bearer '.$authtoken ]; ############################################################################### ### execute the task and parse results ### ############################################################################### try{ $client = new Client(); $response = $client->post($url, [ 'headers' => $hdrs, 'json' => [] ]); } catch (RequestException $e){ echo "Request Failed:". $e->getMessage(); } echo $response->getBody(); ?>
[tabby title=”Python”]
import requests ############################################################################### ### update these accordingly ### ############################################################################### authtoken = 'INSERT_AUTH_TOKEN_HERE' tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' ############################################################################### ### leave these alone ### ############################################################################### url = "https://api.intelepeer.com/sms/v1/{}/provision".format(tn) hdrs = { 'Content-Type': "application/json", 'Authorization': 'Bearer {}'.format(authtoken) } ############################################################################### ### execute the task and parse results ### ############################################################################### response = requests.post(url, json={}, headers=hdrs) print u'{}: {}'.format('OK' if response else 'ERROR', response.text )
[tabbyending]
Configuring a webhook for receiving SMS messages via API
URI
POST to https://api.intelepeer.com/sms/v1/{tn}/webhook
{tn} is the phone number to be configured in E.164 format.
For example, you would configure the webhook for +17208675309 by POST-ing to the URL
https://api.intelepeer.com/sms/v1/+17208675309/webhook
Parameters
This API method requires an Authorization token. Learn more about the Authorization token in Atmosphere® API Authentication.
Parameter | Data Type | Required | Description |
---|---|---|---|
webhook | string | required | The URL to where inbound messages will be posted by IntelePeer |
Example
{ "webhook": "https://www.myserver.com/myapp" }
Response Codes
Response Code | Description |
---|---|
200 | Webhook configuration successfully updated. |
400 | One of the following errors occurred:
|
400 | Improperly-formatted URL provided for the webhook. |
404 | The telephone number is not available for use by the customer. |
Example Code
[tabby title=”C#”]
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IntelePeerSMSExampleClient.inboundWebHook { class SetTNWebHook { public void run() { //Authorization Token from IntelePeer Customer Portal string TN = "INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; string url = "https://api.intelepeer.com/sms/v1/" + TN + "/webhook"; string AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; string WEBHOOK_URL = "INSERT_WEBHOOK_HERE"; System.Net.WebRequest httpWebRequest = System.Net.WebRequest.Create(url); httpWebRequest.Method = "POST"; //Add Header httpWebRequest.ContentType = "application/json"; httpWebRequest.Headers.Add("Authorization", "Bearer " + AUTH_TOKEN); //Data to be posted string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize( new { webhook = WEBHOOK_URL } ); //Add data to post using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } try { //Submit Request and Read Response System.Net.WebResponse httpResponse = httpWebRequest.GetResponse(); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream())) { string result = streamReader.ReadToEnd(); System.Console.Write(result); } } catch (System.Net.WebException webException) { string response = webException.Message; } catch (Exception exception) { string response = exception.Message; } finally { //do something else } } } }
[tabby title=”Java”]
package main.java.tnActions.inboundWebHook; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.httpPost; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; public class SetTnWebHook { public static void main(String... args) throws Exception { final String TN = "INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; final String url = "https://api.intelepeer.com/sms/v1/" + TN + "/webhook"; final String AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; HttpClient httpclient = HttpClientBuilder.create().build(); HttpPost httpPost = new HttpPost(url); // add header httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN); // execute GET HttpResponse response = httpclient.execute(httpPost); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println(result.toString()); } }
[tabby title=”Node.js”]
const request = require("request"); /////////////////////////////////////////////////////////////////////////////// /// update these accordingly /// /////////////////////////////////////////////////////////////////////////////// let authtoken = 'INSERT_AUTH_TOKEN_HERE' let tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' let webhook = 'INSERT_WEBHOOK_URL_HERE' /////////////////////////////////////////////////////////////////////////////// /// leave these alone /// /////////////////////////////////////////////////////////////////////////////// let payload = { 'webhook': webhook } let url = "https://api.intelepeer.com/sms/v1/" + tn +"/webhook" let hdrs = { 'Content-Type': "application/json", 'Authorization': "Bearer " + authtoken } /////////////////////////////////////////////////////////////////////////////// /// execute the task and parse results /// /////////////////////////////////////////////////////////////////////////////// request.post({ url: url, headers: hdrs, form: payload }, (error, response, body) => { let result = JSON.parse(body); console.log(result.text); });
[tabby title=”PHP”]
<?php require '../../vendor/autoload.php'; use GuzzleHttp\Client; ############################################################################### ### update these accordingly ### ############################################################################### $authtoken = 'INSERT_AUTH_TOKEN_HERE'; $tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT'; $webhook = 'INSERT_WEBHOOK_URL_HERE'; ############################################################################### ### leave these alone ### ############################################################################### $url = "https://api.intelepeer.com/sms/v1/$tn/webhook"; $hdrs = ['Content-Type' => "application/json", 'Authorization' => 'Bearer '.$authtoken ]; $payload = ['webhook' => $webhook]; ############################################################################### ### execute the task and parse results ### ############################################################################### try{ $client = new Client(); $response = $client->post($url, [ 'headers' => $hdrs, 'json' => $payload ]); } catch (RequestException $e){ echo "Request Failed:". $e->getMessage(); } echo $response->getBody(); ?>
[tabby title=”Python”]
import requests ############################################################################### ### update these accordingly ### ############################################################################### authtoken = 'INSERT_AUTH_TOKEN_HERE' tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' webhook = 'INSERT_WEBHOOK_URL_HERE' ############################################################################### ### leave these alone ### ############################################################################### payload = { 'webhook': webhook } url = "https://api.intelepeer.com/sms/v1/{}/webhook".format(tn) hdrs = { 'Content-Type': "application/json", 'Authorization': 'Bearer {}'.format(authtoken) } ############################################################################### ### execute the task and parse results ### ############################################################################### response = requests.post(url, json=payload, headers=hdrs) print u'{}: {}'.format('OK' if response else 'ERROR', response.text )
[tabbyending]
Learn more about webhook security in Securing Inbound SMS Webhooks.
Checking the SMS enablement status of a phone number
URI
GET to https://api.intelepeer.com/sms/v1/{tn}/provision
{tn} is the phone number being queried in E.164 format.
For example, you would configure the webhook for +17208675309 by GET-ing from the URL
https://api.intelepeer.com/sms/v1/+17208675309/provision
Parameters
None, however this API method requires an Authorization token. Learn more about the Authorization token in Atmosphere® API Authentication.
Response Example
{ "provisioning": { "state": "requested" } }
Response Variable Values
Variable | Available Values |
---|---|
state |
|
Response Codes
Response Code | Description |
---|---|
200 | Status returned in the response. |
400 | The telephone number is not in the proper E.164 format. |
404 | The telephone number is not available for use by the customer. |
Example Code
[tabby title=”C#”]
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IntelePeerSMSExampleClient.provisioning { class GetTNProvisioningStatus { public void run() { string TN = INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; string url = "https://api.intelepeer.com/sms/v1/" + TN + "/provision"; string AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; System.Net.WebRequest httpWebRequest = System.Net.WebRequest.Create(url); httpWebRequest.Method = "GET"; //Add Header httpWebRequest.ContentType = "application/json"; httpWebRequest.Headers.Add("Authorization", "Bearer " + AUTH_TOKEN); try { //Submit Request and Read Response System.Net.WebResponse httpResponse = httpWebRequest.GetResponse(); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream())) { string result = streamReader.ReadToEnd(); System.Console.Write(result); } } catch (System.Net.WebException webException) { string response = webException.Message; } catch (Exception exception) { string response = exception.Message; } finally { //do something else } } } }
[tabby title=”Java”]
package main.java.tnActions.provisioning; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; public class GetTnProvisioningStatus { public static void main(String... args) throws Exception { final String TN = "INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; final String url = "https://api.intelepeer.com/sms/v1/" + TN + "/provision"; final String AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; HttpClient httpclient = HttpClientBuilder.create().build(); HttpGet httpGet = new HttpGet(url); // add header httpGet.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN); // execute GET HttpResponse response = httpclient.execute(httpGet); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println(result.toString()); } }
[tabby title=”Node.js”]
const request = require("request"); /////////////////////////////////////////////////////////////////////////////// /// update these accordingly /// /////////////////////////////////////////////////////////////////////////////// authtoken = 'INSERT_AUTH_TOKEN_HERE' tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' /////////////////////////////////////////////////////////////////////////////// /// leave these alone /// /////////////////////////////////////////////////////////////////////////////// url = "https://api.intelepeer.com/sms/v1/" + tn +"/provision" hdrs = { 'Content-Type': "application/json", 'Authorization': "Bearer " + authtoken } /////////////////////////////////////////////////////////////////////////////// /// execute the task and parse results /// /////////////////////////////////////////////////////////////////////////////// request.get({ url: url, headers: hdrs }, (error, response, body) => { let result = JSON.parse(body); console.log("response text " + result.text) });
[tabby title=”PHP”]
<?php require '../../vendor/autoload.php'; use GuzzleHttp\Client; ############################################################################### ### update these accordingly ### ############################################################################### $authtoken = 'INSERT_AUTH_TOKEN_HERE'; $tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT'; ############################################################################### ### leave these alone ### ############################################################################### $url = "https://api.intelepeer.com/sms/v1/$tn/webhook"; $hdrs = ['Content-Type' => "application/json", 'Authorization' => 'Bearer '.$authtoken ]; ############################################################################### ### execute the task and parse results ### ############################################################################### try{ $client = new Client(); $response = $client->get($url, [ 'headers' => $hdrs, 'json' => [] ]); } catch (RequestException $e){ echo "Request Failed:". $e->getMessage(); } echo $response->getBody(); ?>
[tabby title=”Python”]
import requests ############################################################################### ### update these accordingly ### ############################################################################### authtoken = 'INSERT_AUTH_TOKEN_HERE' tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' ############################################################################### ### leave these alone ### ############################################################################### url = "https://api.intelepeer.com/sms/v1/{}/provision".format(tn) hdrs = { 'Content-Type': "application/json", 'Authorization': 'Bearer {}'.format(authtoken) } ############################################################################### ### execute the task and parse results ### ############################################################################### response = requests.get(url, json={}, headers=hdrs) print u'{}: {}'.format('OK' if response else 'ERROR', response.text )
[tabbyending]
Checking the Webhook for receiving SMS messages via API
URI
GET to https://api.intelepeer.com/sms/v1/{tn}/webhook
{tn} is the phone number being queried in E.164 format.
For example, you would retrieve the webhook for +17208675309 by GET-ing from the URL
https://api.intelepeer.com/sms/v1/+17208675309/webhook
Parameters
None, however this API method requires an Authorization token. Learn more about the Authorization token in Atmosphere® API Authentication.
Response Example
{ "webhook": "https://www.intelepeer.com/" "tn_e164": "+17208675309" "provisioning": { "state": "provisioned" } }
Response Variable Values
Variable | Available Values |
---|---|
state |
|
Response Codes
Response Code | Description |
---|---|
200 | Webhook returned in the response. |
400 | The telephone number is not in the proper E.164 format. |
404 | The telephone number is not available for use by the customer. |
Example Code
[tabby title=”C#”]
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IntelePeerSMSExampleClient.provisioning { class GetTNProvisioningStatus { public void run() { string TN = INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; string url = "https://api.intelepeer.com/sms/v1/" + TN + "/webhook"; string AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; System.Net.WebRequest httpWebRequest = System.Net.WebRequest.Create(url); httpWebRequest.Method = "GET"; //Add Header httpWebRequest.ContentType = "application/json"; httpWebRequest.Headers.Add("Authorization", "Bearer " + AUTH_TOKEN); try { //Submit Request and Read Response System.Net.WebResponse httpResponse = httpWebRequest.GetResponse(); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream())) { string result = streamReader.ReadToEnd(); System.Console.Write(result); } } catch (System.Net.WebException webException) { string response = webException.Message; } catch (Exception exception) { string response = exception.Message; } finally { //do something else } } } }
[tabby title=”Java”]
package main.java.tnActions.inboundWebHook; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; public class GetTnWebHook { public static void main(String... args) throws Exception { final String TN = "INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; final String url = "https://api.intelepeer.com/sms/v1/" + TN + "/webhook"; final String AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; HttpClient httpclient = HttpClientBuilder.create().build(); HttpGet httpGet = new HttpGet(url); // add header httpGet.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN); // execute GET HttpResponse response = httpclient.execute(httpGet); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println(result.toString()); } }
[tabby title=”Node.js”]
const request = require("request"); /////////////////////////////////////////////////////////////////////////////// /// update these accordingly /// /////////////////////////////////////////////////////////////////////////////// let authtoken = 'INSERT_AUTH_TOKEN_HERE' let tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' /////////////////////////////////////////////////////////////////////////////// /// leave these alone /// /////////////////////////////////////////////////////////////////////////////// let url = "https://api.intelepeer.com/sms/v1/" + tn + "/webhook" let hdrs = { 'Content-Type': "application/json", 'Authorization': "Bearer " + authtoken } /////////////////////////////////////////////////////////////////////////////// /// execute the task and parse results /// /////////////////////////////////////////////////////////////////////////////// request.get({ url: url, headers: hdrs }, (error, response, body) => { let result = JSON.parse(body); console.log("response text " + result.text) });
[tabby title=”PHP”]
<?php require '../../vendor/autoload.php'; use GuzzleHttp\Client; ############################################################################### ### update these accordingly ### ############################################################################### $authtoken = 'INSERT_AUTH_TOKEN_HERE'; $tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT'; ############################################################################### ### leave these alone ### ############################################################################### $url = "https://api.intelepeer.com/sms/v1/$tn/webhook"; $hdrs = ['Content-Type' => "application/json", 'Authorization' => 'Bearer '.$authtoken ]; ############################################################################### ### execute the task and parse results ### ############################################################################### try{ $client = new Client(); $response = $client->get($url, [ 'headers' => $hdrs, 'json' => [] ]); } catch (RequestException $e){ echo "Request Failed:". $e->getMessage(); } echo $response->getBody(); ?>
[tabby title=”Python”]
import requests ############################################################################### ### update these accordingly ### ############################################################################### authtoken = 'INSERT_AUTH_TOKEN_HERE' tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' ############################################################################### ### leave these alone ### ############################################################################### url = "https://api.intelepeer.com/sms/v1/{}/webhook".format(tn) hdrs = { 'Content-Type': "application/json", 'Authorization': 'Bearer {}'.format(authtoken) } ############################################################################### ### execute the task and parse results ### ############################################################################### response = requests.get(url, json={}, headers=hdrs) print u'{}: {}'.format('OK' if response else 'ERROR', response.text )
[tabbyending]
Disabling a number for SMS via API
URI
DELETE to https://api.intelepeer.com/sms/v1/{tn}/provision
{tn} is the phone number to be provisioned in E.164 format.
For example, you would enable +17208675309 for sending/receiving SMS messages by DELETE-ing to the URL
https://api.intelepeer.com/sms/v1/+17208675309/provision
Parameters
None, however this API method requires an Authorization token. Learn more about the Authorization token in Atmosphere® API Authentication.
Response Codes
Response Code | Description |
---|---|
202 | The deprovisioning request has been accepted and is pending completion. |
400 | The reason for the error is contained within the response. |
401 | The reason for the error is contained within the response. |
409 | Provisioning (or deprovisioning) of the number is in progress. |
Behavior
Deprovisioning can only be requested when a number is in the provisioned state.
Example Code
[tabby title=”C#”]
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IntelePeerSMSExampleClient.provisioning { class GetTNProvisioningStatus { public void run() { string TN = INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; string url = "https://api.intelepeer.com/sms/v1/" + TN + "/provision"; string AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; System.Net.WebRequest httpWebRequest = System.Net.WebRequest.Create(url); httpWebRequest.Method = "DELETE"; //Add Header httpWebRequest.ContentType = "application/json"; httpWebRequest.Headers.Add("Authorization", "Bearer " + AUTH_TOKEN); try { //Submit Request and Read Response System.Net.WebResponse httpResponse = httpWebRequest.GetResponse(); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream())) { string result = streamReader.ReadToEnd(); System.Console.Write(result); } } catch (System.Net.WebException webException) { string response = webException.Message; } catch (Exception exception) { string response = exception.Message; } finally { //do something else } } } }
[tabby title=”Java”]
package main.java.tnActions.provisioning; import java.io.BufferedReader;< import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpDelete; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; public class DeprovisionTn { public static void main(String... args) throws Exception { final String TN = "INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT"; final String url = "https://api.intelepeer.com/sms/v1/" + TN + "/provision"; final String AUTH_TOKEN = "INSERT_AUTH_TOKEN_HERE"; HttpClient httpclient = HttpClientBuilder.create().build(); HttpDelete httpGet = new HttpDelete(url); // add header httpGet.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN); // execute GET HttpResponse response = httpclient.execute(httpGet); System.out.println("\nSending 'DELETE' request to URL : " + url); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println(result.toString()); } }
[tabby title=”Node.js”]
const request = require("request"); /////////////////////////////////////////////////////////////////////////////// /// update these accordingly /// /////////////////////////////////////////////////////////////////////////////// let authtoken = 'INSERT_AUTH_TOKEN_HERE' let tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' /////////////////////////////////////////////////////////////////////////////// /// leave these alone /// /////////////////////////////////////////////////////////////////////////////// let url = "https://api.intelepeer.com/sms/v1/" + tn +"/provision" let hdrs = { 'Content-Type': "application/json", 'Authorization': "Bearer " + authtoken } /////////////////////////////////////////////////////////////////////////////// /// execute the task and parse results /// /////////////////////////////////////////////////////////////////////////////// request.delete({ url: url, headers: hdrs }, (error, response, body) => { let result = JSON.parse(body); console.log("response text " + result.text) });
[tabby title=”PHP”]
<?php require '../../vendor/autoload.php'; use GuzzleHttp\Client; ############################################################################### ### update these accordingly ### ############################################################################### $authtoken = 'INSERT_AUTH_TOKEN_HERE'; $tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT'; ############################################################################### ### leave these alone ### ############################################################################### $url = "https://api.intelepeer.com/sms/v1/$tn/webhook"; $hdrs = ['Content-Type' => "application/json", 'Authorization' => 'Bearer '.$authtoken ]; ############################################################################### ### execute the task and parse results ### ############################################################################### try{ $client = new Client(); $response = $client->delete($url, [ 'headers' => $hdrs, 'json' => [] ]); } catch (RequestException $e){ echo "Request Failed:". $e->getMessage(); } echo $response->getBody(); ?>
[tabby title=”Python”]
import requests ############################################################################### ### update these accordingly ### ############################################################################### authtoken = 'INSERT_AUTH_TOKEN_HERE' tn = 'INSERT_TELEPHONENUMBER_HERE_IN_E.164_FORMAT' ############################################################################### ### leave these alone ### ############################################################################### url = "https://api.intelepeer.com/sms/v1/{}/provision".format(tn) hdrs = { 'Content-Type': "application/json", 'Authorization': 'Bearer {}'.format(authtoken) } ############################################################################### ### execute the task and parse results ### ############################################################################### response = requests.delete(url, json={}, headers=hdrs) print u'{}: {}'.format('OK' if response else 'ERROR', response.text )
[tabbyending]