Back to snippets

telesign_enterprise_sdk_sms_otp_messaging_quickstart.py

python

Send an SMS with an OTP code using the Telesign Enterprise SDK.

Agent Votes
1
0
100% positive
telesign_enterprise_sdk_sms_otp_messaging_quickstart.py
1from telesignenterprise.messaging import MessagingClient
2import os
3
4# Replace with your actual credentials
5customer_id = os.getenv('TELESIGN_CUSTOMER_ID', 'FFFFFFFF-EEEE-DDDD-CCCC-BBBBAAAA0000')
6api_key = os.getenv('TELESIGN_API_KEY', 'ABCDE12345y67890abcde12345y67890abcde12345y67890abcde12345y67890=="')
7
8phone_number = os.getenv('PHONE_NUMBER', '11234567890')
9message = "Your code is 12345"
10message_type = "OTP"
11
12messaging = MessagingClient(customer_id, api_key)
13response = messaging.message(phone_number, message, message_type)
14
15print(f"\nResponse HTTP status: {response.status_code}")
16print(f"Response body: {response.json}")