Send an SMS Using JSON API
To send an SMS using JSON API, the following format is used:
curl -X POST \
'<BASE_URL>&method=sms.json&json=%7B%22sms%22%3A%20%5B%7B%20%22to%22%3A%20%229xxxxxxxx......%7D%5D%20%7D'
SMS can be sent using the JSON API by posting values to the preceding URL by the POST method with urlencoded json data.
Sample JSON data
{
"sms":
[{
"to": "9xxxxxxxx",
"custom": 9xxxxxxxx,
"message": "Message from json api node 1"
},
{
"to": "91xxxxxxxx",
"custom": 34,
"message": "Message from json api node 2"
}]
}
API Parameter Specifications
The API parameter specifications are described in the following sections.
Mandatory Parameters
The mandatory parameters in the HTTP API are tabulated below:
Parameter | Description | Expected Values |
---|---|---|
BASE_URL | BASE URL of your SMS Service | URL |
method | Predefined method | sms.json |
json | You can provide either URL encoded XML data directly or URL of the JSON file | Valid JSON document or link of JSON document |
Optional Parameter
The Optional parameters in the HTTP API are tabulated below:
Parameter | Description | Expected Values |
---|---|---|
format | Output format should be as specified by this variable | XML/PHP/JSON/JSONP. Default response will be in JSON |
callback | Callback function for JSONP response format | Javascript function name standards |
JSON Tag Parameters
Note: If message,sender and dlrurl is specified within both SMS tag and JSON tag, the former overrides the later.
Parameter | Description | Expected Values | Type | ||
---|---|---|---|---|---|
flash | Global node for flash | 1/0 | Optional | ||
sms | SMS Node(can repeat) | SMS Node | Mandatory | ||
to | Mobile number in sms node | Comma separated 10 digit mobile numbers | Required | ||
custom | Message ID for sms | comma separated message ID's | Optional | ||
custom1 | Custom reference 1 (comma separate) | comma separated custom 1 references | Optional | ||
custom2 | Custom reference 2 (comma separate) | comma separated custom 2 references | Optional | ||
sender | Sender ID assigned to your account | Sender ID | Mandatory | ||
message | Message to be sent. | Message text | Mandatory | ||
dlrurl | The URL to receive delivery reports. Spiffing reference id is mandatory | EX: http://www.example.com/dlr.php |
Optional | ||
unicode | To specify that the message to be sent is in unicode format. Also can be used for automatic detection of unicode SMS | 1/0/auto | Optional | ||
time | Global schedule time | EX Format: YYYY-MM-DD HH:MM:SS OR YYYY-MM-DD HH:MM AM/PM | Optional |
a. Sending to multiple numbers with same message
{
"message": "test json",
"sms":[
{
"to": "95XXXXXXXX",
"msgid": "1",
"message": "test sms",
"custom1": "11",
"custom2": "22",
"sender": "AAAAAA"
},
{
"to": "99XXXXXXXX",
"msgid": "2",
"custom1": "1",
"custom2": "2"
}],
"unicode": 1,
"flash": 1,
"dlrurl": "http://www.example.com/dlr.php"
}
b. Sending to multiple numbers with different message
{
"message": "test json",
"sms":[
{
"to": "95XXXXXXXX",
"msgid": "1",
"message": "test sms",
"custom1": "11",
"custom2": "22",
"sender": "AAAAAA"
},
{
"to": "99XXXXXXXX",
"msgid": "2",
"message": "json test sms",
"custom1": "1",
"custom2": "2"
}],
"unicode": 1,
"flash": 1,
"dlrurl": "http://www.example.com/dlr.php"
}
Sample Response
JSON
{
"status": "OK",
"data": [
{
"id": "811436f5-0053-4ea6-8cac-b035880b8473:1",
"customid": "1",
"customid1": "11",
"customid2": "22",
"mobile": "95XXXXXXXXX",
"status": "AWAITED-DLR"
},
{
"id": "811436f5-0053-4ea6-8cac-b035880b8473:2",
"customid": "2",
"customid1": "1",
"customid2": "2",
"mobile": "97XXXXXXXX",
"status": "AWAITED-DLR"
}
],
"message": "Campaign of 2 numbers Submitted successfully."
}