API Authentication

To use our APIs, you first need to obtain an authentication token. To do this, you must create an API Access user in the Customer Portal.

Create a New User with API Access

  1. Log into the Customer Portal.
  2. From the menu at the left side of the page, click User Management.
  3. Click the Create New User/Contact button.

  1. On the User/Contact Details pop-up, fill in the Full Name, Email, and Phone.
  2. Click Create Login.
  3. Enter a unique name in the Username field, and select API from the Access drop-down list.
  4. Click Save.

An email with your username and password is automatically sent to the email address you entered.

Obtain Your Token

Once you have created an API Access user, you can use one of two methods to obtain your token.

Through the CPaaS Portal

To retrieve a long-standing token for use with the CPaaS List Management API, log into the CPaaS Portal. On the landing page, API Authentication Token section, click Copy. You're ready to go!

Through the Customer Portal

To retrieve a short-term, 24-hour token for use with all other APIs, using the username and password you created for the API Access user, make the following request:

Note: Once the 24-hour token expires, repeat the request to get a new token.

Request

POST https://customer.intelepeer.com/_rest/v4/authenticate

Content-Type: application/json

Accept: application/json

Important: If you are using Postman to send your API requests, make sure to add the following Keys in the Headers section: Content-Type: application/json and Accept: application/json


{
	
	"username": "YOUR USERNAME",
	
	"password": "YOUR PASSWORD"
	
}
			

Success Response

Successful authentication. Token returned in the body of the response.

Status: 200
{
"token":"fFkq..."
}

Related Errors

Status: 401
{
"code":401,
"error":"Unauthorized"
}

Note: If you are unable to retrieve your token, confirm the user you created has been granted API access in the Customer Portal, and your username and password accuracy in the body of the request.

Code Examples

Example


package main.java.authorization;

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 GetToken {
    public static void main(String... args) throws Exception {
        final String url = "https://customer.intelepeer.com/_rest/v4/authenticate";
        final String USERNAME = "INSERT_USERNAME";
        final String PASSWORD = "INSERT_PASSWORD";

        HttpClient httpclient = HttpClientBuilder.create().build();
        HttpPost httpPost = new HttpPost(url);

        // add header
        httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
        httpPost.setHeader(HttpHeaders.ACCEPT, "application/json");

        // Data to be posted
        List urlParameters = new ArrayList();
        urlParameters.add(new BasicNameValuePair("username", USERNAME));
        urlParameters.add(new BasicNameValuePair("password", PASSWORD));

        // add data to post
        httpPost.setEntity(new UrlEncodedFormEntity(urlParameters));

        // execute post
        HttpResponse response = httpclient.execute(httpPost);

        // show post results
        System.out.println("nSending 'POST' request to URL : " + url);
        System.out.println("Post parameters : " + httpPost.getEntity());
        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());
    }
}

Example

const request = require("request");
///////////////////////////////////////////////////////////////////////////////
/// update these accordingly                                                ///
///////////////////////////////////////////////////////////////////////////////
let data = { "username": "INSERT_USERNAME", "password": "INSERT_PASSWORD" }

///////////////////////////////////////////////////////////////////////////////
/// leave these alone                                                       ///
///////////////////////////////////////////////////////////////////////////////
let url  = "https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token"
let hdrs = {  'Content-Type': "application/json", 'Accept': "application/json"}

///////////////////////////////////////////////////////////////////////////////
/// execute the task and parse results                                      ///
///////////////////////////////////////////////////////////////////////////////
request.get({
        url: url,
        headers: hdrs
    },
    (error, response, body) => {                
        let result = JSON.parse(body);
        console.log(result.token);
});

Example

"INSERT_USERNAME", "password" => "INSERT_PASSWORD" ];

###############################################################################
### leave these alone                                                       ###
###############################################################################
$url  = "https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token";
$hdrs = ['Content-Type' => "application/json", 'Accept' => "application/json"];

###############################################################################
### execute the task and parse results                                      ###
###############################################################################

try{
  $client = new Client();
  $response = $client->post($url, [
    'headers' => $hdrs,
    'json' => $data
    ]);
}
catch (RequestException $e){
  echo "Request Failed:". $e->getMessage();
}

echo $response->getBody();
?>

Example

import requests

###############################################################################
### update these accordingly                                                ###
###############################################################################
data = { "username": "INSERT_USERNAME", "password": "INSERT_PASSWORD" }

###############################################################################
### leave these alone                                                       ###
###############################################################################
url  = "https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token"
hdrs = {  'Content-Type': "application/json", 'Accept': "application/json" }

###############################################################################
### execute the task and parse results                                      ###
###############################################################################
response    = requests.post(url, json=data, headers=hdrs)
status_code = response.status_code
text        = response.text
token = None
try:
    token = response.json().get(u'token')
except: pass

print u'{}: {}'.format('OK' if response else 'ERROR', response.text )