HTTP API - 'sendmessage' action
This http api command can be used to send an SMS message via the SMS Gateway. The command can be used to send text SMS messages or other message types, such as binary SMS messages, operator logos, ringtones, WAP PUSH, etc... When you use this command, you must use an http api username and password, you must specify the recipient phone number, and the message text.
Description
To send an SMS, use the following URL format:
https://127.0.0.1:9508/api?action=sendmessage&username=UUUUU&password=PPPPP&
recipient=NNNNN&messagetype=MMMMM&messagedata=DDDDD
127.0.0.1 is a local IP, so please replace it to the IP address or host name of the computer
with the installed Ozeki SMS Gateway. (Note: 127.0.0.1 is a local
loopback address that can be used when you are connecting to the SMS Gateway
from the same computer.) 9508 is the default port of Ozeki SMS
Gateway's HTTP API. This port number can be viewed and edited in Ozeki 10 SMS Gateway-s
user interface, by clicking on the Advanced button in the toolbar.
"UUUUU" and "PPPPP" should be replaced to the username and password of the
user you have created in the SMS gateway.
Substitute "NNNNN" to the phone number you wish to send the SMS message to.
You can use the local phone number format as well as international phone
number formats (telephone numbers formatted according to the international number
format always start with a '+' sign). If the international phone number format is used,
note that you must substitute '%2B' for the '+' character, because of URL
encoding rules.
Please substitute "MMMMM" for the message type. "SMS:TEXT" message type should be used for
text messages.
The message data contains the message you would like to send. Place the message data instead of "DDDDD". The message data should be
using UTF-8 characters and should be
URL encoded.
Other parameters can also be added to the request.
For a complete list of available parameters please take a look at the 'Request parameters' table below:
Example URL Request
https://127.0.0.1:9508/api?action=sendmessage&username=admin&password=abc123&
recipient=06203105366&messagetype=SMS:TEXT&messagedata=Hello+World
Example Response
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 246 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE smsapi PUBLIC "-//OZEKI//DTD XML 1.0//EN" "http://www.ozekisms.com/DTD/smsapi.xml"> <response> <action>sendmessage</action> <data> <acceptreport> <statuscode>0</statuscode> <statusmessage>Message accepted for delivery</statusmessage> <messageid>ERFAV23D</messageid> <recipient>06203105366</recipient> </acceptreport> </data> </response>
HTTP request parameters
Parameter | Description | Possible values | Example | M/O* |
action | Specifies the HTTP API command | sendmessage | action=sendmessage | M |
username | Specifies the username. The username and password parameters are used to authenticate the user. When you send a message it will be sent in the name of the authenticated user. The value must be url-encoded. | string value, maximum length is 16 characters | username=admin | M |
password | Specifies the password. The username and password parameters are used to authenticate the user. When you send a message it will be sent in the name of the authenticated user. The value must be url-encoded. | string value, maximum length is 16 characters | password=abc123 | M |
originator | Specifies the sender address. This information will be displayed on the mobile phone, that receives the message. This is the sender address. This can be a telephone number, a short code or an alphanumeric sender address. The telephone number must can be formatted in local number format (e.g.06201234567) or in international number format (e.g.+36201234567). If you use an alphanumeric sender address (e.g.ozeki), the characters must be encoded in UTF8 and the value must be url-encoded. | string value, maximum length is 16 characters | originator=%2B36201112222 | O |
recipient | Specifies the recipient phone number.
The message will be sent to this telephone number. The telephone number
can be specified in local number format (e.g.06201234567), or in
international number format (e.g.+36201234567). More than one recipient addresses can be separated by a colon (e.g.: +36201234567,+36202222222) or semi-colon. The value must be url-encoded. |
string value, maximum length is 16 characters | recipient=%2B36201234567 | M |
messagetype | Specifies the message type.
The type of the SMS message data based on the
Mobile Message Type Specification.
For text messages the message data will be plain text, for other message
types it will be an XML document.
|
SMS:TEXT SMS:WAPPUSH ... Possible values can be found in the Mobil Message Type Specification |
messagetype=SMS:TEXT | O |
messagedata | Specifies the text or the data of the SMS message. The value must be encoded in UTF8 and must be url-encoded. | string value, maximum length is 32768 characters | messagedata=Hello+World | M |
_charset_ | Specifies the charset of the encoded data (if not specified utf-8
will be assumed).
Newer browsers should set the value of _charset_ automatically. If your
browser doesn't support this feature, you can set is manually to: |
utf-8 windows-1250 iso-8859-1 iso-8859-2 ... (Supported character set values) |
_charset_=iso-8859-2 | O |
serviceprovider | Specifies the name of the GSM Modem or IP SMS service provider
connection to use to send the message.
More information about service provider connection selection is
available in
the HTTP SMS API - SMS routing
guide.
The value must match the string specified on the configuration form of the service provider connection. |
string value, maximum length is 16 characters | serviceprovider=Vodafone | O |
sendondate | Specifies the date and time, when the message should be sent.
The value must use the following date format: YYYY-MM-DD hh:mm:ss. The value must be url-encoded |
date value in YYYY-MM-DD hh:mm:ss format | sendondate=2018-12-12+10%3A07%3A05 | O |
responseformat | After the gateway submits the SMS message, the gateway will return a web page indicating that the message was submitted successfully. The content of the webpage is formatted according to the responseformat parameter. You can have html text response to make it easy for humans to read it or you can have xml format to make it easy for software to process the response. |
xml (default) html urlencoded |
responseformat=xml | O |
continueurl | After the gateway submits the SMS message, the gateway will return a
web page indicating that the message was submitted successfully. The
content
of the webpage is formatted according to the responseformat
parameter. If the responseformat parameter is set to html, the webpage
can contain a "Continue" link. If you specify the URL in this parameter,
the continue link will be displayed and it will point to the specified
URL. The value of the URL must be url-encoded.
The URL you specify can contain keywords that will be replaced to state information corresponding to the submitted message. More information about possible keywords can be found in the "Submit URL keywords" guide. |
string value, maximum length is 1024 characters | continueurl=192.168.1.23 or continueurl=http%3A%2F%2Fwww.ozekisms. com%2Findex.php%3Fowpn%3D159 Note: the second example contains an urlencoded URL. |
O |
redirecturl | After the gateway submits the SMS message, by default the gateway
will return a web page indicating that the message was submitted
successfully. Optionally you can ask the gateway to automatically
redirect the browser to an URL you specify. If you specify an URL in
the redirect parameter, the HTTP response returned
by the SMS gateway will contain a redirect URL in the HTTP header. This
will instruct the web browser to follow the link you have specified. The
value of the URL must be
url-encoded.
The URL you specify can contain keywords that will be replaced to state information corresponding to the submitted message. More information about possible keywords can be found in the "Submit URL keywords" guide. |
string value, maximum length is 1024 characters | redirecturl=192.168.1.23 or redirecturl=http%3A%2F%2F192.168.1.23 %2Findex.php%3Fowpn%3D159 Note: the second example contains an urlencoded URL. |
O |
reporturl | You can setup a webpage to process information about "delivered
to network" and "delivered to handset" events. If you
specify an URL in the reporturl parameter, your webpage will be
called when these events happen. The value of the URL you specify in
the reporturl parameter must be
URL encoded.
The URL you specify can contain keywords that will be replaced to state information corresponding to the submitted message. A good example on how to use the report URL option can be found in the how to send a scheduled sms and use the reporturl functionality guide. |
string value, maximum length is 1024 characters | reporturl=http%3A%2F%2Fwww.ozekisms. com%2Fproc.php%3Freporttype%3D%24reporttype %26messageid%3D%24messageid Note: this is the urlencoded version of the following URL. Before this URL is called by the SMS gateway, the $reporttype and $messageid parameters will be replaced to the appropriate values: http://192.168.1.23/proc.php?reporttype=$reporttype& messageid=$messageid will be called as: http://192.168.1.23/proc.php?reporttype=deliveredtonetwork& messageid=ERFAV23D The list of keywords you can use in the reporturl are: $reporttype $messageid $statuscode $statusmessage $fromstation $fromconnection $fromaddress $tostation $toconnection $toaddress $text $createdate $submitdate $receiveddate |
O |
messagecount | It specifies the exact number of messages you would like to send. If set, indexing is needed for the 'recipient', 'messagetype' and 'messagedata' parameters. The detailed 'messagecount' tutorial can be found here. | number (default value: 1) |
messagecount=6 | O |
maxresponse | This number specifies the maximum of messages about which you will receive feedback. If you exceed this number, your messages will be sent out, but you won't receive feedback about them. By default, this parameter is set to 500 messages. | number | maxresponse=1000 | O |
vp | Specifies the validity period for your message.
The value must use the following date format: YYYY.MM.DD hh:mm:ss. The value must be url-encoded. Read this tutorial for more information. |
date value in YYYY.MM.DD hh:mm:ss format | vp=2019.01.28.+10%3A07%3A05 | O |
* M = Mandatory parameter, O = Optional parameter
Response parameters
(xml response format)
Parameter | Description | Possible values | Example |
acceptreport | Contains the response for the submit request for a single recipient address. If many recipients were specified, an acceptreport will be included in the response for each recipient. The order of acceptreports will match the order of the recipient addresses. | <acceptreport> <statuscode>0</statuscode> <statusmessage>Message accepted for delivery</statusmessage> <messageid>ERFAV23D</messageid> <recipient>06203105366</recipient> </acceptreport> |
|
acceptreport.statuscode | Contains an integer value to indicate success or failure. If the value is 0, it means the message was accepted for delivery. If the value is greater than 0 it means there was an error, the message was not accepted for delivery. | Integer value, greater than or equal to 0. Less the 32768. | <statuscode>0</statuscode> |
acceptreport.statusmessage | Contains a textual representation of the status code. If the message was accepted the value will be "Message accepted for delivery". If the message was not accepted for delivery, you can find the error message in this field. | string value, maximum length is 1024 characters | <statusmessage>Message accepted for delivery</statusmessage> |
acceptreport.messageid | Contains a message reference that can be used to track the message in the SMS gateway. This message reference is also used to identify delivered to network and delivered to handset reports or to query information about the message. | string value, maximum length is 16 characters | <messageid>ERFAV23D</messageid> |
acceptreport.recipient | Contains the recipient address. | string value, maximum length is 16 characters | <recipient>06203105366</recipient> |
Summary
This article was about the HTTP API ‘sendmessage’ action. With this action, you can send text SMS messages and many other message types to any recipients through the Ozeki SMS Gateway. You have seen example responses and some more http requests with description, possible values and examples.
If you would like to know more about the delivery status of your messages, feel free to click the page about SMS delivery statuses. If you would like to get a URL template, visit the page for it.
If you would like to use this solution in real situations, download the Ozeki SMS Gateway and start using it now!
More information