TeleSign SDK
The TeleSign Python SDK simplifies integration with TeleSign's REST APIs for user verification, digital identity, and omnichannel communications, helping to secure onboarding, maintain account integrity, and prevent fraud. It wraps various TeleSign services, including Messaging, Verify, and Intelligence. The library is actively maintained, with version 4.0.1 being the latest release, receiving regular updates and patches.
Warnings
- breaking Version 4.0.0 and 3.0.0 removed all functionality and methods for the Legacy Intelligence Use Case API and the App Verify SDK. Users relying on these legacy APIs must migrate to newer services.
- breaking With TeleSign Python SDK v4.0.0 and the launch of Intelligence Cloud, legacy GET-based Intelligence methods (e.g., from `PhoneIdClient`) are no longer supported. Integrations using these methods must switch to POST-based methods (e.g., from `ScoreClient`).
- gotcha HTTP Keep-Alive connections can cause 'connection reset by peer' errors if idle for more than 499 seconds. While v2.3.1 added automatic HTTP session recycling, older integrations or specific network configurations might still encounter this.
- gotcha Versions of the SDK prior to v4.0.1 and v3.0.1 may encounter issues with newer `setuptools` versions due to the removal of `pkg_resources`.
Install
-
pip install telesign
Imports
- MessagingClient
from telesign.messaging import MessagingClient
- Verify
from telesign.api import Verify
Quickstart
import os
from telesign.messaging import MessagingClient
CUSTOMER_ID = os.environ.get('TELESIGN_CUSTOMER_ID', 'YOUR_CUSTOMER_ID')
API_KEY = os.environ.get('TELESIGN_API_KEY', 'YOUR_API_KEY')
PHONE_NUMBER = os.environ.get('TELESIGN_PHONE_NUMBER', '11234567890') # E.164 format
MESSAGE = "Your package has shipped!"
MESSAGE_TYPE = "ARN"
if CUSTOMER_ID == 'YOUR_CUSTOMER_ID' or API_KEY == 'YOUR_API_KEY':
print("Please set TELESIGN_CUSTOMER_ID and TELESIGN_API_KEY environment variables or replace placeholders.")
else:
try:
messaging_client = MessagingClient(CUSTOMER_ID, API_KEY)
response = messaging_client.message(PHONE_NUMBER, MESSAGE, MESSAGE_TYPE)
if response.ok:
print(f"Message sent successfully: {response.json}")
else:
print(f"Error sending message: {response.json}")
except Exception as e:
print(f"An unexpected error occurred: {e}")