Send an SMS Message with Python

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. Set up your Python application
  2. Send your first SMS message

Set up your Python application

Create your file

Create a new file named send-sms.py and paste the provided "Send an SMS message" code into the file.

Fill in your parameters

  1. Assign your values to the following parameters:
    ParameterYour value
    servicePlanIdThe service plan ID found on your Customer Dashboard.
    apiTokenThe API token found on your Customer Dashboard. Click Show to reveal your API token.
    sinchNumberAny 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.
    toNumberThe 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.

  2. 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 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

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