Learn how to quickly send SMS messages in a Python application with the Sinch SMS API.
The easiest way to install the SDK is using
- Open a command prompt or terminal to the local repository folder.
- Execute the following command:
pip install sinch
Now you can start setting up your application.
send-sms.pyand paste the provided "Send an SMS message" code into the file.
Send an SMS message
from sinch import Client sinch_client = Client( key_id="YOUR_key_id", key_secret="YOUR_key_secret", project_id="YOUR_project_id" ) send_batch_response = sinch_client.sms.batches.send( body="Hello from Sinch!", to=["YOUR_to_number"], from_="YOUR_Sinch_number", delivery_report="none" ) print(send_batch_response)
This code initalizes the Sinch Client and then sends a message using the
The code provided includes placeholder parameters. You'll need to update the parameters detailed in the following subsections with your values.
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
Assign your values to the following parameters:
|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.|
|The phone number to which you want to send the test SMS message.|
Ensure that you save the file.
Now you can execute the code and send your test SMS message. Run the following command:
send-sms.pyfile uses the Sinch SDK
batchesendpoint to send the SMS message. Click here to read more about the
- Visit our API specification to test more endpoints.