Telesign Enterprise SDK

4.0.1 · active · verified Mon Apr 13

The TeleSign Enterprise SDK for Python simplifies integration with TeleSign's APIs for phone verification, SMS messaging, and fraud prevention services. It allows developers to quickly add security and communication features to their applications. The current version is 4.0.1, and the library maintains an active development status with updates primarily released to support new TeleSign API features, address critical bugs, or incorporate breaking changes from their backend services.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `RestClient` with your TeleSign Customer ID and API Key (preferably from environment variables) and then use it to send an SMS message and perform a PhoneID lookup. Ensure you replace the placeholder values or set corresponding environment variables.

import os
from telesign.rest import RestClient

CUSTOMER_ID = os.environ.get('TELE_CUSTOMER_ID', 'YOUR_CUSTOMER_ID')
API_KEY = os.environ.get('TELE_API_KEY', 'YOUR_API_KEY')
PHONE_NUMBER = os.environ.get('TELE_PHONE_NUMBER', '+1234567890') # E.164 format

if __name__ == '__main__':
    if CUSTOMER_ID == 'YOUR_CUSTOMER_ID' or API_KEY == 'YOUR_API_KEY' or PHONE_NUMBER == '+1234567890':
        print("Please set TELE_CUSTOMER_ID, TELE_API_KEY, and TELE_PHONE_NUMBER environment variables or replace placeholders.")
    else:
        try:
            telesign_client = RestClient(CUSTOMER_ID, API_KEY)
            # Example: Send an SMS message
            response = telesign_client.sms.message(PHONE_NUMBER, "Hello from TeleSign!", message_type="ARN")

            if response.status_code == 200:
                print(f"SMS message sent successfully: {response.json()}")
            else:
                print(f"Failed to send SMS message: {response.status_code} - {response.json()}")

            # Example: Check PhoneID (basic)
            phoneid_response = telesign_client.phoneid.standard(PHONE_NUMBER, {}) # Second arg is optional 'ucid'
            if phoneid_response.status_code == 200:
                print(f"PhoneID Standard lookup successful: {phoneid_response.json()}")
            else:
                print(f"Failed PhoneID Standard lookup: {phoneid_response.status_code} - {phoneid_response.json()}")

        except Exception as e:
            print(f"An error occurred: {e}")

view raw JSON →