Send an SMS Message with Python SDK
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.
- PIP (package installer for Python) and a familiarity with how to install Python modules.
Learn how to quickly send SMS messages in a Python application with the Sinch SMS API.
Installing the SDK
The easiest way to install the SDK is using pip
:
- Open a command prompt or terminal to the local repository folder.
- Execute the following command:
pip install sinch
Set up your Python application
Now you can start setting up your application.
Create your file
Create a new file namedsend-sms.py
and paste the provided "Send an SMS message" code into the file.This code initalizes the Sinch Client and then sends a message using the
batches
class.Modify your application
The code provided includes placeholder parameters. You'll need to update the parameters detailed in the following subsections with your values.
Initialize the client
Before initializing a client using this SDK, you'll need three pieces of information:
- Your Project ID
- An access key ID
- An access key Secret
Note:
If you have trouble accessing the above link, ensure that you have gained access to the Conversation API by accepting the corresponding terms and conditions.
Fill in remaining parameters
Assign your values to the following parameters:
Parameter | Your value |
---|---|
YOUR_Sinch_number | 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. |
YOUR_to_number | The phone number to which you want to send the test SMS message. |
Ensure that you 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 uses the Sinch SDK 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.