Enabling SMS for a Phone Number via API

Overview

Enable any number in your account for SMS using /provision.

 

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 CodeDescription
202The provisioning request has been accepted and is pending completion.
400The reason for the error is contained within the response.
401The reason for the error is contained within the response.
409Provisioning (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

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

 

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

 

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->post($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.post(url, json={}, headers=hdrs)
print u'{}: {}'.format('OK' if response else 'ERROR', response.text )