TeleSign SDK

4.0.1 · active · verified Mon Apr 13

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

Install

Imports

Quickstart

This quickstart demonstrates how to send an SMS message using the `MessagingClient`. It retrieves TeleSign credentials and the recipient's phone number from environment variables, or uses placeholders if not set. After initializing the client, it attempts to send a message and prints the API response.

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

view raw JSON →