This document contains information required for Content Providers to send and receive SMS messages to mobile-phone subscribers using the TeletopiaSMS HTTP XML API Gateway interface. The interface is intended for developers and requires basic knowledge of HTTP and XML. To use this interface you will need a TeletopiaSMS Gateway account.
The interface is designed to allow a simple and robust implementation regardless of which platform the Content Provider decides to implement their solution.
In order to receive messages sent from end-users (MO or mobile originated) or delivery reports (DLR), the Content Provider must specify a URL, which is configurable through our service configuration web pages.
Advantages of using this API include:
$ netcat api1.teletopiasms.no 80 POST /gateway/v3/xml HTTP/1.1 Host: api1.teletopiasms.no Content-Type: application/xml Content-Length: xxx <submitRequest> <auth> <username>xxx</username> <password>xxx</password> </auth> <messages> <message> <recipient>4700000000</recipient> <contentText> <text>Hello World</text> </contentText> </message> </messages> </submitRequest>
The response from the gateway will be in the following format:
<submitResponse> <responses> <response> <accepted>1</accepted> <messageId>unique_message_id</messageId> <recipient>4700000000</recipient> <statusCode>1000</statusCode> <statusDescription>accepted</statusDescription> </response> </responses> </submitResponse>
All TeletopiaSMS HTTP based API services are available as HTTPS (SSL encrypted) as well as HTTP. We recommend using HTTPS whenever possible as HTTP is mainly provided for compatibility with older systems.
Should the primary end-point become unreachable, we have backup end-points available. We encourage the Content Providers to design their systems to switch URL’s whenever they lose connection. Do not try to load-balance by sending round robin or random. Use secondary as a fallback if primary fails.
The available end-points are:
Secure web service for send (primary) | https://api1.teletopiasms.no/gateway/v3/xml |
Secure web service for send (secondary) | https://api2.teletopiasms.no/gateway/v3/xml |
Secure web service for send (tertiary) | https://api3.teletopiasms.no/gateway/v3/xml |
URL for send (primary) | http://api1.teletopiasms.no/gateway/v3/xml |
URL for send (secondary) | http://api2.teletopiasms.no/gateway/v3/xml |
URL for send (tertiary) | http://api3.teletopiasms.no/gateway/v3/xml |
The HTTP XML API allows submitting multiple message per request. The XML message object must be submitted using HTTP POST requests. The Content-type for the request SHOULD be set to "application/xml".
This section describes the protocol used by the Content Providers to send SMS messages to mobile-phone subscribers, from here on referred to as MT or mobile terminated messages.
<submitRequest> <auth> <username></username> <password></password> </auth> <messages> <message> <clientRef></clientRef> <gateway></gateway> <senderType></senderType> <sender></sender> <recipient></recipient> <expire></expire> <sendTime></sendTime> <requestDlr></requestDlr> <price></price> <ageLimit></ageLimit> <serviceCode></serviceCode> <tag></tag> <contentText> <dcs></dcs> <text></text> <recodeText></recodeText> </contentText> <contentSmsText> <dcs></dcs> <pid></pid> <udh></udh> <text></text> </contentSmsText> <contentSmsBinary> <dcs></dcs> <pid></pid> <udh></udh> <ud></ud> </contentSmsBinary> </message> </messages> </submitRequest>
Only one of contentText, contentSmsText and contentSmsBinary may be present in the message object.
Field name | Field type | Size (max) | Mandatory | Description |
---|---|---|---|---|
username | String | yes | Username for gateway. | |
password | String | yes | Password for gateway. | |
clientRef | String | 100 | no | This is an optional Content Provider generated message id. This id will be included in delivery reports. |
tag | String | 100 | no | Optional string to "tag" a message, e.g. service name. Makes it possible to split statistics, search in logs. |
senderType | Integer | no | Type of sender number.
| |
sender | String | no | Sender number or alphanumeric sender id. Alphanumeric sender id should only be letters and digits, maximum 11 characters. See more information about alphanumeric sender addresses. NOTE: Use international format including country code when using numeric sender. | |
recipient | String | yes | Recipient number (MSISDN). The format of the number is E.164, without any leading + or trunk prefix. (Example: 4712345678). | |
gateway | String | no | Ignore unless otherwise instructed by TeletopiaSMS. | |
expire | String | no | The time at which the message should no longer be attempted to be delivered to the recipient. This field will be used when the operators support message expiration dates, otherwise the operator default value will be used. See datatypes section for supported date format. | |
sendTime | String | no | The time at which the message should be sent. The message will be stored until the specified time before it is sent. The message route and cost will be decided at the time the message is sent. See datatypes section for supported date format. | |
requestDlr | Integer | no | Request deliver report for message. Set to 1 to enable (default) and 0 to disable. | |
Parameters for the text content type | ||||
dcs | Integer | no | Data coding scheme. The specified value must be 0-255. If dcs is not specified the GSM 7-bit alphabet will be used unless the text contains characters not part of the GSM 7-bit alphabet, in which case UCS2 will be used. If dcs is set to 0, the message will be sent using the GSM 7-bit alphabet, all characters not supported by this alphabet will be replaced either by ? (question mark) or with a similar-looking character from the GSM 7-bit alphabet. | |
text | String | yes | Text content. Long messages will be split into multiple SMS. | |
recodeText | Integer | no | Instruct the gateway to convert the text content.
| |
Parameters for the textsms content type | ||||
dcs | Integer | no | Data coding scheme. The specified value must be 0-255. | |
pid | Integer | no | Protocol identifier. This value is not supported for all carriers. The specified value must be 0-255. | |
udh | String | 280 | no | User data header specified as a hex encoded string. See more information about hex encoded strings. |
text | String | 160 | yes | Text content. Maximum 140 bytes (160 characters in GSM 7-bit alphabet) |
Parameters for the binarysms content type | ||||
dcs | Integer | yes | Data coding scheme. The specified value must be 0-255. | |
pid | Integer | no | Protocol identifier. This value is not supported for all carriers. The specified value must be 0-255. | |
udh | String | 280 | no | User data header specified as a hex encoded string. See more information about hex encoded strings. |
ud | String | 280 | yes | User data specified as a hex encoded string. The combined maximum length of the udh and ud is 140 bytes (or 280 characters as a hex encoded string). See more information about hex encoded strings. |
The success of the send request is determined by the HTTP status code. Status code 200 means success. Some important HTTP status codes:
Code | Response Type | Description |
---|---|---|
200 | Success | Request was understood by the gateway, check the response body for the submit status. |
400 | Bad Request | Request is invalid or contains invalid/unsupported data. |
403 | Forbidden | Authentication failed. |
500 | Internal Server Error | An error occurred when processing the message. |
<submitResponse> <responses> <response> <accepted></accepted> <clientRef></clientRef> <messageId></messageId> <recipient></recipient> <statusCode></statusCode> <statusDescription></statusDescription> </response> </responses> </submitResponse>
Field name | Field type | Mandatory | Description |
---|---|---|---|
accepted | Integer | yes | Value indicating whether message was accepter or not:
|
clientRef | String | no | The custom identifier of the message. This value may be specified when a message is submitted |
messageId | String | no | Unique message id generated by TeletopiaSMS for the message. |
recipient | String | no | The recipient specified in the send request. |
statusCode | String | yes | The status code. This is a more detailed version of the accepted field. See section for delivery report status codes. |
statusDescription | String | yes | Human readable string describing the status code. |
This section describes the protocol used to receive delivery reports when using the HTTP XML API. The XML delivery report objects are sent as the body a HTTP POST request. You will need to enable reports and configure an URL in the gateway administration control panel.
Always return HTTP status code 200 when receiving gateway requests. Any other code will trigger a re-send and could possibly stall the queue of delivery reports. In case there is an error in your system, if a database server is not working, you can return HTTP status code 500. We will then wait for some time, and try to resend at a later time.
<dlr> <messageId></messageId> <clientRef></clientRef> <delivered></delivered> <statusCode></statusCode> <time></time> <timestamp></timestamp> <mcc></mcc> <mnc></mnc> <partCount></partCount> </dlr>
Field name | Field type | Mandatory | Description |
---|---|---|---|
messageId | String | yes | The identifier of the message, this is the id returned when submitting a message. |
clientRef | String | no | The custom identifier of the message. This value may be specified when a message is submitted. |
delivered | Integer | yes | Value indicating whether message was delivered or not:
|
statusCode | Integer | yes | The status code. This is a more detailed version of the delivered field. See section for delivery report status codes. |
time | String | yes | The time at which the delivery report was received by TeletopiaSMS from operator (RFC 3339 format). |
timestamp | Number | yes | The time at which the delivery report was received by TeletopiaSMS from operator (in milliseconds from 1970-01-01 UTC). |
mcc | String | no | The MCC country code the message was routed to. Note this parameter may not always be available. |
mnc | String | no | The MNC operator code the message was routed to. Note this parameter may not always be available. |
partCount | Number | yes | The number of SMS message parts the text message was split into by TeletopiaSMS. |
Code | Description |
---|---|
1000 | Message in transit, not yet delivered |
2000 | Message has been successfully delivered to recipient |
50xx | Access failed |
5000 | Access failed |
60xx | Message rejected |
6000 | Message rejected |
6001 | Invalid recipient MSISDN |
6002 | Invalid sender-id |
6004 | Invalid content |
6005 | Recipient country is blocked for your account |
70XX | Message undeliverable |
7000 | Message undeliverable |
7001 | Message unroutable (usually invalid msisdn) |
7002 | Rejected by operator: Rejected payload |
7003 | Technical error |
7005 | Rejected by operator: Undeliverable (usually unknown subscriber) |
90xx | Expired |
9000 | Expired |
This section describes the protocol to forward user-originated SMS when using the HTTP XML API. The XML messages objects are sent as the body a HTTP POST request. You will need to enable message reception and configure an URL in the gateway administration control panel.
Always return HTTP status code 200 when receiving gateway requests. Any other code will trigger a re-send and could possibly stall the queue of messages. In case there is an error in your system, if a database server is not working, you can return HTTP status code 500. We will then wait for some time, and try to resend at a later time.
<deliverMsg> <messageId></messageId> <recipient></recipient> <sender></sender> <text></text> </deliverMsg>
Field name | Field type | Mandatory | Description |
---|---|---|---|
messageId | String | yes | The identifier of the message. |
sender | String | yes | The phone number of the end-user this message came from. The format of the number is E.164, without any leading + or trunk prefix. (Example: 4712345678). |
recipient | String | yes | The number the message was sent to. This can be a shortcode, a national number or an international number. |
text | String | yes | Message content sent by end-user. |
All dates are specified using the format described in RFC 3339, unless otherwise noted.
Example of timestamps using the format specified in RFC 3339:
2015-11-27T22:54:33Z 2015-11-27T22:54:33.231Z 2015-11-27T22:54:33.231+01:00
The SMS Gateway will always send timestamps containing the fractional seconds part, but it will accept timestamps both with and without fractional seconds.
Alphanumeric numbers may be up to 11 characters long. We will accept any character string of length 11 and less, but not all characters are supported by all the operators. We recommend only using the following characters:
Note that space characters should also be avoided as not all operators support this.
Hex encoded strings are used as a way to specify binary data in a text document. The string "Hello" will result in the byte array [48, 65, 6C, 6C, 6F]
when using utf-8 encoding. The hex string is the string representing the values in this array using 2 characters per value: "48656C6C6F"
.
Examples of making a hex string:
>>> import binascii >>> binascii.hexlify('Hello'.encode('utf8')) b'48656c6c6f'
javax.xml.bind.DatatypeConverter.printHexBinary("Hello".getBytes(StandardCharsets.UTF_8));
bin2hex('Hello');
> Buffer.from('Hello').toString('hex'); '48656c6c6f'
price
and ageLimit
parameters for MT messages#
and !
from recommended characters in alphanumeric senders.tag
parameter description for MT messagessenderType
parameter for MT messagessender
parameter for MT messagesrequestDlr
and sendTime
parameters.mcc
, mnc
, time
, timestamp
and partCount
parameters in delivery report.recodeText
parameterrecodeText
delivered
(0/1) parameter to JSON and XML delivery report