Phone ID - Tutorial: Use identity attributes

This tutorial walks you step-by-step through how to write code that makes a request to Phone ID that includes the Contact identity attribute.

An identity attribute provides additional information about a phone number with one call to Phone ID. This is in addition to the standard response fields for Phone ID. You get back status information for each identity attribute enabled and requested.

Before you begin

Make sure you have the following ready:


  1. Copy the sample code below into a file on your local machine.
  2. Install the requests module and HTTPBasicAuth from requests.auth.


from requests.auth import HTTPBasicAuth
import requests
  1. Insert values for the following variables:
  • complete_phone_number - The phone number you want to get information about.
  • CUSTOMER_ID - Your Telesign Customer ID.
  • API_KEY - Your Telesign API Key.
  1. Run the program. If the call is successful, you should get a response payload that looks like this:
  "contact": {
    "address1": "2432 CHIMNEY POINT LN",
    "address2": "",
    "address3": "",
    "address4": "",
    "city": "LEXINGTON",
    "country": "",
    "first_name": "MYLA",
    "last_name": "JONES",
    "state_province": "KY",
    "status": {
      "code": 2800,
      "description": "Request successfully completed"
    "zip_postal_code": "40509",
    "email_address": "[email protected]"

Sample code

from requests.auth import HTTPBasicAuth
import requests

url = '<complete_phone_number>'
headers = {'Accept' : 'application/json', 'Content-Type' : 'application/json'}
r =, auth=HTTPBasicAuth('CUSTOMER_ID', 'API_KEY'), json={'addons':{'contact':{}}}, headers=headers)

require 'net/http'
require 'uri'
require 'json' 
require 'rest-client'

response ={
      method: :post,
      url: '<complete_phone_number>',
      user: 'Customer ID',
      password: 'API Key',
      payload: { 'addons': {'contact':{}} },
      headers: { :accept => :json, content_type: :json }
    }).execute do |response, request, result|
      case response.code
      when 400
        [ :error, JSON.parse(response.to_str) ]
      when 200
        [ :success, JSON.parse(response.to_str) ]
        fail "Invalid response #{response.to_str} received."