HTTP API - Send SMS

From Ultiroam User Docs
Jump to navigation Jump to search

POST https://gateway_ip/api/send_sms

Request Parameters:

Parameter Type Description
Required Parameters
text String The content of SMS, support grammar like #param#
param Array of Object Each element is an object, which can be any of the following :

number: a digit string no more than 24 bytes

text_param: an array of string. Each element is used to replace #param# in the text

user_id: an integer greater than or equal to 0.

It is recommended the user_id is an unique value for each SMS. user_id is the index of SMS, which is used to identify the SMS while user query SMS sending result. (refer to 3 “Query SMS sending Result” )

Optional Parameters:
port Array of Integer Number of port for sending SMS

Each port number should be an integer, ranging from 0 to 31

encoding String It can be ‘unicode’or ‘gsm-7bit’ Default is ‘unicode’
request_status_report Boolen It is used to determine whether to use SMS status report. It can be true or false.

Default is true.

Response Parameters:

Parameter Type Description
error_code Integer Codes that may be returned:

202: Request has been accepted and will be processed later;

400: Request format is not valid

413: the count of telephone numbers is more than 128 or text content is over 1500 bytes

500: other errors

550: No available port for sending sms.

sn String SN of the gateway
sms_in_queue Integer Number of SMS messsages waiting for being processed
task_id Integer Used to stop corresponding sending task later

Example of sending SMS

Simple Request:

curl -k --anyauth -u admin:admin -d  '{"text":"ye","param":[{"number":"10086"}]}' -H "Content-Type:  application/json" https://gateway_ip/api/send_sms

Request with #param:

curl -k --anyauth -u admin:admin -d  '{"text":"#param#","port":[2,3],"param":[{"number":"10086","text_param":["bj"],"user_id":1},{"number":"10086",

"text_param":["ye"],"user_id":2}]}' -H "Content-Type:  application/json" https://gateway_ip/api/send_sms

Note:

1. The example above comes with the default username and password. Use the real username and password of your own gateway.

2.  Use the real IP address of your gateway to replace the gateway_ip.

Response:

{"error_code":202,"sn":"xxxx-xxxx-xxxx-xxxx","sms_in_queue":2,"task_id":2}