Checking if a number is enabled for SMS

Overview

Check the status of SMS provisioning for a number using /provision

 

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
VariableAvailable Values
state
  • requested
  • provisioning
  • provisioned
  • derequested
  • deprovisioning
  • error

 

Response Codes
Response CodeDescription
200Status returned in the response.
400The telephone number is not in the proper E.164 format.
404The telephone number is not available for use by the customer.

 

Example Code

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());
    }
}

 

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)
});

 

PHP

<?php

require '../../vendor/autoload.php';
use GuzzleHttpClient;

###############################################################################
### 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();
?>

 

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 )