Sending SMS with Python using Sendchamp API

A quick walk-through on how to seamlessly implement Sendchamp SMS API with Python

Aliyu Abubakar

Aug 2, 2021

Learn how to quickly send SMS messages with Python using sendchamp API. In this guide we will walk you through:

  1. Signing up free sendchamp account
  2. Create a Sender ID
  3. Setting up your Python Application
  4. Sending your first message

Prerequisite

Before you can get started, you need the following already set up: You have python installed. If you don't, read about how to install it on your system here.

  • A sendchamp account
  • Signing up free sendchamp account

If you already have an account? skip to the next section You can sign up for a free sendchamp account here.

image

When you sign up, you'll have to verify your email address. This allows sendchamp to verify your identity.

After you've verified your email address, you'll be asked a question in order to get you started in a way that's relevant to you.

After you finish setting up your account, you'll have access to your dashboard where you can access your API Key and perform dashboard communication functions.

Create a Sender ID

Once your account is created, you’ll need to add a new sender ID in order to send SMS Messages. Click channels on your dashboard under settings, click sms channel and add a sender ID. Take note of your ID, because you'll use it later.

image

Setting up your Python Application

First, you’ll need to create a file send.py to save your code.


import requests

url = "https://api.sendchamp.com/api/v1/sms/send"

payload="{\n    \"to\": [\"2348055372961\"],\n    
\"message\": \"Hello from Olumide Latest\",\n   
 \"sender_name\": \"Kuda\"\n
\"route\": \"non_dnd\"\n}"
headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer ACCESS_KEYEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Replace URL with either a test or live BASE URL depending on what you intend to do.

Replace Authorization under HEADER with your test or live Access key depending on what you intend to do.

Parameters

  • You need numbers to send messages to and from.
  • Set the value of (to) to any number (or numbers) you want to receive the message.
  • Set the value of the sender_name token to your Sender ID on your sendchamp dashboard.
  • Set route to dnd, non_dnd or international.

Sending your SMS message

Now you can execute the code and send your test SMS message.

Run the following script:

send.py 

The code you used in the send.py file sends a POST request to the sendchamp API endpoint to send the SMS message.

© 2022 Sendchamp. All rights reserved.