Send to Signal with REST using Python

Sending messages to Signal users with the REST API using the Python programming language

The requests library can be used to make REST requests using Python to send SMS.

REST requirements and resources

REST (REpresentational State Transfer) uses the HTTP protocol (HTTPS) for conveying Signal operations. A REST Signal API account can easily be obtained for using the Melrose Labs Signal API. REST uses JSON to carry the parameters that relate to the REST operation that you are performing. The following are required to send a Signal message with REST:

Signal API account
Account credentials for the Melrose Labs Signal API

Getting started with the Signal API and REST
Signal API REST documentation

Python requirements and resources

Python is a programming language and can be used to quickly and easily add messaging support for programmatically sending and receiving messages. Use it for transactional messaging and notifications between your application and mobiles. The following are required to send Signal messages using Python:

Python
Python programming language

Requirements and resources

The following are required to send Signal messages with REST using Python:

requests
Python Requests library

Code

Create the file sendsignal.py containing the code below. Replace the [SYSTEMID] and [PASSWORD] values with those for your Melrose Labs Signal API account.

The following example Python code makes a REST HTTPS call to the Melrose Labs Signal API endpoint to send the message Hello World €£$ to mobile number 447712345678 from MelroseLabs. The transaction ID for the message is returned by the endpoint after a successful submission.

#!/usr/bin/python
# -*- coding: iso-8859-15 -*-

import requests
import json

url = "https://api.melroselabs.com/signal/message"

payload = {
        "systemid": "[SYSTEMID]",
        "password": "[PASSWORD]",
        "destination": "447712345678",
        "text": "Hello World €£$"
}
headers = {
  'Content-Type': 'application/json'
}

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

print(response.text.encode('utf8'))