Send SMS to devices using curl command or Python script

Apart from the simplicity that Hologram gives you send SMS messages to your devices through the dashboard, you might want to play a little with your device and try some other cool ways that you can do this as well.

To send SMS messages via commands or scripts to your device, here are two simple options you can try.

 

Curl command in Unix

Use the command below in your terminal and make sure to replace all the values in between <> with your own details.

curl --location --request POST 'https://dashboard.hologram.io/api/1/sms/incoming' --header 'Content-Type: application/json' --header 'Authorization: Basic <your apikey>' --data-raw '{"deviceid":"<your device id>","fromnumber":"<your from number>","body":"<your sms message>"}'

 

Python script

Use the script below in a .py file and make sure to replace all the values in between <> with your own details.

import requests
from requests.auth import HTTPBasicAuth

# Authentication
usr = 'apikey'
pwd = '<your apikey>'

# Vars
dev = "<your device id>"
num = "<your from number>"
sms = "<your sms message>"

# Send SMS
response = requests.post(
'https://dashboard.hologram.io/api/1/sms/incoming',
data = {
"deviceid": dev,
"fromnumber":num,
"body": sms
},
auth = HTTPBasicAuth(usr, pwd)
)
# Logs
print(response.json())
Was this article helpful?
0 out of 0 found this helpful