Send an SMS Message with Python
Note:
Before you can get started, you need the following already set up:
- Set all SMS API configuration settings.
- Python and a familiarity with how to create a new app.
Learn how to quickly send SMS messages in a Python application with the Sinch SMS API.
Set up your Python application
Create your file
Create a new file namedsend-sms.py
and paste the provided "Send an SMS message" code into the file.Fill in your parameters
- Assign your values to the following parameters:
Parameter Your value servicePlanId
The service plan ID found on your Customer Dashboard. apiToken
The API token found on your Customer Dashboard. Click Show to reveal your API token. sinchNumber
Any number you've assigned to your Sinch account. Find the number on your Customer Dashboard by clicking the service plan ID link and scrolling to the bottom of the page. toNumber
The phone number to which you want to send the test SMS message. Double check that the region is correct on your base URL. Learn more about regional options here.
- Save the file.
Send your first SMS message
Now you can execute the code and send your test SMS message. Run the following command:
python send-sms.py
Next steps
The code you used in thesend-sms.py
file sends a POST request to the Sinch API /batches
endpoint to send the SMS message. Click here to read more about the batches endpoint.Additional resources
- Visit our API specification to test more endpoints.