Send an SMS Message with Python SDK

Note:

Before you can get started, you need the following already set up:

Learn how to quickly send SMS messages in a Python application with the Sinch SMS API.

Steps:
  1. Install the Python SDK
  2. Set up your Python application
  3. Send your first SMS message

Installing the SDK

The easiest way to install the SDK is using pip:

  1. Open a command prompt or terminal to the local repository folder.
  2. Execute the following command:
    Copy
    Copied
    pip install sinch

Set up your Python application

Now you can start setting up your application.

Create your file

Create a new file named send-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
These values can be found on the Access Keys page of the Customer Dashboard. You can also create new access key IDs and Secrets, if required.
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:

ParameterYour value
YOUR_Sinch_numberAny 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_numberThe 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:

Copy
Copied
python send-sms.py

Next steps

The code you used in the send-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

We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.