Sending MT SMS
In order to deliver SMS-MT messages, Data is transferred using HTTP GET/POST requests. The Onfon gateway accepts requests at the following URL:
https://api.onfonmedia.co.ke/v1/sms/SendBulkSMS
HTTP request parameters :
Parameter Name | Description | Type |
---|---|---|
ApiKey | ApiKey used for authentication purpose. | String |
ClientId | ClientId used for authentication purpose. | String |
SenderId | Approved Sender Id | String |
MessageParameters | Array hollding one or more messages | |
Number | Recepient Mobile number | string |
Text | Text message to be sent out | string |
scheduleTime (optional) | ScheduleTime Date in yyyy-MM-dd HH:MM (only for schedule message) | string |
Headers
Parameter Name |
---|
Content-Type: application/json |
AccessKey: xxxxxxxx-xxxx-xxxx-xxxx |
Sample JSON request :
{
"SenderId": "string",
"IsUnicode": true,
"IsFlash": true,
"ScheduleDateTime": "string",
"MessageParameters": [
{
"Number": "7894561230",
"Text": "string"
},
{
"Number": "7894561231",
"Text": "string"
}
],
"ApiKey": "string",
"ClientId": "string"
}
HTTP Response
Successful response:
{
"ErrorCode": 0,
"ErrorDescription": "Success",
"Data": [
{
"MobileNumber": "7894561230",
"MessageId": "fc103131-5931-4530-ba8e-aa223c769536"
},
{
"MobileNumber": "7894561231",
"MessageId": "f893293d-d6ea-45e8-b543-40f0df28e0c9"
}
]
}
Examples
Here is an example of how to send an SMS via POST:
import requests
import urllib
url = "https://api.onfonmedia.co.ke/v1/sms/SendBulkSMS"
payload = "{
"SenderId": "XXXXX",
"MessageParameters": [
{
"Number": "254703012012",
"Text": "Test Message"
},
{
"Number": "254703012013",
"Text": "Test Message"
}
],
"ApiKey": " xxxxxxxx-xxxx-xxxx-xxxx",
"ClientId": " xxxxxxxx-xxxx-xxxx-xxxx"
}"
headers = {
'Content-Type': "application/json",
'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)