/
SMS REST API

SMS REST API

Before you begin

Please make sure that CONNECT Support has provided you with the following information:

Username, Password, platformId, platformPartnerId

If you will be receiving Delivery Reports for your messages, please provide CONNECT Support with an URL and they will also give you a gateId to use. For more information on Delivery Reports, see the “Delivery Reports” chapter.

To use Delivery Reports, make sure you have made an opening in any firewalls so that Common can connect to you to transfer Delivery Reports. The addresses to open for are listed here.

Scope of this document

This document will describe the Application Programming Interface (API) to send text messages through the CONNECT“Common” platform. It will also describe the mechanism for delivering, to your platform, Delivery Reports for each message sent.

A separate page describes the API for receiving text messages.

Common is a REST API. This means it uses HTTP verbs to receive commands. A basic familiarity with REST APIs is assumed, as well as a familiarity with JSON.

Capabilities of “Common” platform

Common is a high-capacity, high-availability SMS Gateway designed to let you send and receive SMS Text messages, as well as receive a notification when the text message is received by the end-user.

A message can be free for the end-user to receive, or it can cost money. (Certain countries only). In certain markets, you can charge the end-users without actually sending them a message, so-called "Silent billing".

A message can be of any length up to the maximum defined by the GSM standard (254 segments)

It can contain any character in the UTF-8 2-byte character set. (Unicode 4-byte characters are not supported).

When sending free messages, the sender of the message can be set to any string of 2-11 characters, a-Z,0-9 (Must begin with a non-numeric character).

Common tracks the status of each message every step of the way until it is delivered to the end-user’s handset, and will provide you with this status through a Delivery Report. Delivery Reports can be sent in JSON, HTTP GET or POST formats.

Sending MT messages

Base URL

You will get one of these URL:s assigned to you when your account is created:

https://wsx.sp247.net/sms

 

Authentication

 

There are two ways of doing authentication: OAuth 2.0 or Basic Authentication.

OAuth 2.0
The preferred way of authentication is using OAuth 2.0. It requires the client to obtain a token to be used in other requests.
The only grant type currently supported is “client_credentials” where the “client_id” is the username and “client_secret” is the password provided by Support.
This would be posted to the access token URL as:
POST /auth/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=user&client_secret=secret
Successful result with HTTP status 200:
{"access_token":"xxxxxxx","token_type":"Bearer","expires_in":3599}
The access_token value should be used as a header in requests to be used for authorization:
Authorization: Bearer xxxxxx
The max age for a token is specified in the expires_in field in seconds.
Unsuccessful results will return a different HTTP status than 200 and the body will contain a error parameter in a JSON object with any of the following results: invalid_request, unsupported_grant_type, invalid_client or internal_error.

Authenticate in the HTTP request using Basic Authentication with the username and password provided by Support.

HTTP Methods, statuses, and actions

HTTP Method

Message sent

Message sent, no response


No access

Invalid request

Invalid login

POST

200 OK

Returns SendResponse

204 No Content

403 Forbidden
Returns ErrorResponse

400 Bad Request
Returns ErrorResponse

401 Unauthorized
Returns ErrorResponse

Methods

 

POST /sms/send

Submits a message object for delivery to a mobile phone. Set Content-Type: application/json in your request header and POST a JSON object with the following properties:

 

Parameter

Data type

Description

source

String

Required. This is the source number from where the message should be sent. The format is depending on the specified sourceTON.

sourceTON

TON

This is the source type of number. See allowed TON values below. 
Default ALPHANUMERIC.

destination

String

Required. This is the destination number. The format is depending on the specified destinationTON. Remember that MSISDNS include the country code and a leading plus sign. (+)

destinationTON

TON

This is the destination type of number. See allowed TON values below. 
Default MSISDN.

dcs

DCS

Advanced.

This is the Data Coding Scheme that should be used when sending the SMS. See allowed DCS values in a separate table. 
Default TEXT.

userDataHeader

String

Advanced.

This value may be specified when sending concatenated SMS, WAP-push, etc. The format is hex encoded 8-bit bytes. More information about valid UDH for long SMS may be given by Support upon request. Common will handle the splitting and concatenation of messages if you do not have a specific reason to do it yourself.

userData

String

This is the message content itself. The DCS specifies the format (encoding) on this value.

Note that messages that messages of more than 140 bytes must be split into multiple messages. Common will do that automatically by default.

useDeliveryReport

Boolean

True indicates that a delivery report should be sent back when the message has come to a final state. (Delivered or failed)

TRUE is mandatory for premium messages.

Defaults to TRUE, and it is recommended to use delivery reports.

deliveryReportGates

List
<String>

One or more gates that should be used for sending delivery reports. If you do not specify any Gates to deliver Delivery Reports to, make sure to set useDeliveryReport to FALSE. See the chapter on delivery reports for more information. Required for premium messages.

relativeValidityTime

Long

This specifies how long the message is supposed to live. If the message takes longer to deliver to the handset than the validityTime, the message will be discarded.

The value is specified in milliseconds.

Default is 48 hours (172800000).

absoluteValidityTime

Date

The absolute time when a message should expire. Minimum 15 minutes and maximum 48h in the future. Formatted according to RFC3339, e.g. 2010-03-30T12:59:40+02:00. Overrides relativeValidityTime if both are set.

tariff

Integer

Price, in local currency, in 1/100 of currency. For example, to send a message costing 5 NOK, this should be set to 500.

If you are splitting a long message into multiple segments yourself, set price only on the first segment.

Default 0.

currency

Currency

The currency should be set if the default country currency not to be used. Supported currencies are NOK, SEK, DKK, EUR, LTL.
Ignored for non-premium messages.

vat

Integer

Deprecated - implementations should not use this field any more.

 

The VAT that used for the premium transaction, default differ per market. 2500 equals 25%. Absence or value = -1 means not set.
Ignored for non-premium messages.

age

Integer

Allowed age for (adult) content.
Optional. Not supported by all operators.

priority

Priority

See the Priority value table, Optional. 

platformId

String

Your platformId. Provided to you by Support.

platformPartnerId

String

Your platformPartnerId. Provided to you by Support.

refId

String

Your own internal transaction ID. Not used for anything except as a reference.
Optional. 

productDescription

String

When sending premium messages, a description of the service. This will be printed on the end-user’s phone bill.
Ignored for non-premium messages.

productCategory

Integer

When sending premium messages, specify which category the service is. This lets the operator know which rates to apply to the message. Support or your sales contact will help you determine the correct productCategory to set.
Ignored for non-premium messages.

moReferenceId

String

A reference to the ID of the MO message which triggered the MT message. Required for some operators.

customParameters

KeyValue

Advanced. Additional parameters may be specified if needed.

Support will advise you if you need to use custom parameters.

ignoreResponse

Boolean

Indicates whether you want a response in the body when you submit the message. This is not a delivery report, only a confirmation of message submission. 

Default is false.

DCS

Data Coding Scheme sets the encoding used for the message. Default and recommended is TEXT.

DCS value

Description

GSM

GSM-7 default alphabet encoding.

BINARY

8-bit binary data.

UCS2

UCS-2 encoding

TEXT

Server-side handling of encoding and segmenting. Recommended.

TON

TON stands for Type of Number and designates how a number is to be interpreted.

TON value

Description

SHORTNUMBER

Shortnumber; 1-14 digits depending on country.

ALPHANUMERIC

Up to 11 valid GSM characters. Some operators and some handsets don’t accept all characters. Safe characters are a-z, A-Z, 0-9.

MSISDN

A mobile number, international format, starting with +.

Priority

It gives the sending a certain priority.

Priority value

Description

HIGH

For high priority of sending

NORMAL

For normal priority of sending

LOW

For low priority of sending

Error Result Codes

Result Code

Description

101100

Invalid authentication. Please check your username and password.

101101

Access denied. Please check your username and password.

106000

Unknown Error. Please contact Support and include your whole transaction.

106001

Parse Error. The object to send in the request is badly formatted.

106102

Unable to access SMSC credentials

106200

Invalid or missing platformId. Please check your platformId.

106201

Invalid or missing platformPartnerId. Please check your platformPartnerId.

106202

Invalid or missing currency for premium message. Please check your price and currency.

106300

No gates available. Please contact Support and include your whole transaction.

106301

Specified gate unavailable. Please check your gateId.

Example

In this example, the platformId and platformPartnerId and deliveryReportGates are set to invalid values. The values that are correct for you will be provided by Support.

A minimal example, including only required fields. This would send the message “Hello world” to the Norwegian phone number +46735964545, and not use a delivery report. The sender is set to “CONNECT”.

This JSON would be POSTed to https://[your assigned URL]/sms/send

 

{ "source" : "CONNECT" , "useDeliveryReport": false, "sourceTON" : "ALPHANUMERIC" , "destination" : "+46735964545" , "destinationTON" : "MSISDN" , "dcs" : "TEXT" , "userData" : "Hello World" , "priority" : "NORMAL" , "quality" : "NORMAL" , "platformId" : "SERGEL" , "platformPartnerId" : "4587" }

 

Success Result

On a successful request, Common will reply with HTTP 200 OK, or HTTP 204 No Content if “ignoreResponse” is set to TRUE.

In the body you will find the messageId of the message:

{ "messageId":"Dcshuhod0PMAAAFQ+/PbnR3x", "resultCode":1005, "description":"Queued" }

 

If the customParameter “replySmsCount” with the case insensitive String value “true” is found in the sending request, then the reply will have an extra parameter called “smsCount” that has an integer value, it shows the amount of message parts or SMS sent per SendRequestMessage.

{ "messageId":"Dcshuhod0PMAAAFQ+/PbnR3x", "resultCode":1005, "description":"Queued", "smsCount":1 }

 

If there’s an invalid value or the case insensitive String value “false”, then the “smsCount” parameter wouldn’t be shown. The returned smsCount is a preliminary value, an estimation, of message parts and the final smsCount will be found in the delivery report.

Please note that this is not a delivery report. Save the messageId; when the delivery report arrives, it will include the same messageId.

Batch sending MT messages

If you want to send many messages at one time, you can use the Batch Sender to send multiple messages at once, reducing connection overhead. You will receive an array of responses when you submit, with the messageId and refId of each message posted.

Sending a batch MT message is similar to sending a single MT message, except that certain parameters are moved into a sendRequestMessages parameter, which you then post an array of.

The names and types and functions of all parameters except sendRequestMessages are the same as if you were sending a single MT message. Delivery reports are handled normally.

The URL for submitting batch messages is

https://[your assigned URL]/sms/sendbatch

batchSendRequest

Parameter

Data type

Description

useDeliveryReport

Boolean

True indicates that a delivery report should be sent back when the message has come to a final state. (Delivered or failed)

TRUE is mandatory for premium messages.

Defaults to TRUE, and it is recommended to use delivery reports.

deliveryReportGates

List
<String>

One or more gates that should be used for sending delivery reports. If you do not specify any Gates to deliver Delivery Reports to, make sure to set useDeliveryReport to FALSE. See the chapter on delivery reports for more information. Required for premium messages.

relativeValidityTime

Long

This specifies how long the message is supposed to live. If the message takes longer to deliver to the handset than the validityTime, the message will be discarded.

The value is specified in milliseconds.

Default is 48 hours (172800000).

absoluteValidityTime

Date

The absolute time when a message should expire. Minimum 15 minutes and maximum 48h in the future. Formatted according to RFC3339, e.g. 2010-03-30T12:59:40+02:00. Overrides relativeValidityTime if both are set.

priority

Priority

See the Priority value table, optional.

platformId

String

Your platformId. Provided to you by Support.

platformPartnerId

String

Your platformPartnerId. Provided to you by Support.

customParameters

KeyValue

Advanced. Additional parameters may be specified if needed.

Support will advise you if you need to use custom parameters.

ignoreResponse

Boolean

Indicates whether you want a response in the body when you submit the message. This is not a delivery report, only a confirmation of message submission. 

Default is true.

sendRequestMessages

List
<sendRequestMessage>

An array of messages. The maximum number of messages allowed within the array is 1000. See the following table for its content.

 

 

sendRequestMessage

Parameter

Data type

Description

source

String

Required. This is the source number from where the message should be sent. The format is depending on the specified sourceTON.

sourceTON

TON

This is the source type of number. See allowed TON values below. 
Default ALPHANUMERIC.

destination

String

Required. This is the destination number. The format is depending on the specified destinationTON. Remember that MSISDNS include the country code and a leading plus sign. (+)

destinationTON

TON

This is the destination type of number. See allowed TON values below. 
Default MSISDN.

dcs

DCS

Advanced.

This is the Data Coding Scheme that should be used when sending the SMS. See allowed DCS values in a separate table. 
Default TEXT.

userDataHeader

String

Advanced.

This value may be specified when sending concatenated SMS, WAP-push, etc. The format is hex encoded 8-bit bytes. More information about valid UDH for long SMS may be given by Support upon request. Common will handle the splitting and concatenation of messages if you do not have a specific reason to do it yourself.

userData

String

This is the message content itself. The DCS specifies the format (encoding) on this value.

Note that messages that messages of more than 140 bytes must be split into multiple messages. Common will do that automatically by default.

tariff

Integer

Price, in local currency, in 1/100 of currency. For example, to send a message costing 5 NOK, this should be set to 500.

If you are splitting a long message into multiple segments yourself, set price only on the first segment.

Default 0.

currency

Currency

The currency should be set if the default country currency not to be used. Supported currencies are NOK, SEK, DKK, EUR.
Ignored for non-premium messages.

vat

Integer

Deprecated - implementations should not use this field anymore.

 

The VAT that used for the premium transaction, default differ per market. 2500 equals 25%. Absence or value = -1 means not set.
Ignored for non-premium messages.

age

Integer

Allowed age for (adult) content.
Optional. Not supported by all operators.

refId

String

Your own internal transaction ID. Not used for anything except as a reference.
Optional. 

productDescription

String

When sending premium messages, a description of the service. This will be printed on the end-user’s phone bill.
Ignored for non-premium messages.

productCategory

Integer

When sending premium messages, specify which category the service is. This lets the operator know which rates to apply to the message. Support or your sales contact will help you determine the correct productCategory to set.
Ignored for non-premium messages.

 

The acceptable productCategory values are specified under productCategory values.

moReferenceId

String

A reference to the ID of the MO message which triggered the MT message. Required for some operators.

customParameters

KeyValue

Advanced. Additional parameters may be specified if needed.

Support will advise you if you need to use custom parameters.

 

These additional parameters are overridden by those that are in the batchSendRequest.

FInd product categories here CONNECT productCategories

FInd product categories here STREX productCategories

Batch sending example

The following JSON would send a message to two recipients at the same time.

Success Result

On a successful request, Common will reply with HTTP 200 OK, or HTTP 204 No Content if “ignoreResponse” is set to TRUE. In the body you will find an array of Json objects, every object is the result of every message sent, and the messageId of every message too:

 

 

If the customParameter “replySmsCount” with the case insensitive String value “true” is found in the sending request, then the reply will have an extra parameter called “smsCount” that has an integer value, it shows the amount of message parts or SMS sent per SendRequestMessage in all the messages sent.

 

If there’s an invalid value or the case insensitive String value “false”, then the “smsCount” parameter wouldn’t be shown.

Please note that this is not a delivery report. Save the messageId; when the delivery report arrives, it will include the same messageId.

Sending flash sms

This is possible by just adding the customParameter “flash.sms” with the case insensitive String values “true” or “false” within the request object. The default value for this customParameter is “false”.

Example within the object to POST in /sms/send/

 

In the case of batch sendings, this value can be added within the batchSendRequest or within the SendRequestMessage. But if this customParameter is added within the batchSendRequest, then it will override its value for all the messages within this single batchSendRequest.

 

Example 1

Here, all the messages will be sent as flash sms, even if the flash.sms customParameter is found with the value “false”within a sendRequestMessage:

 

Example 2

Here, the first message will be sent as a flash SMS, meanwhile the second one and the third one will be sent as normal SMS. This will work if the customParameter “flash.sms” is absent in the batchSendRequest.

 

Scheduled delivery of MT messages

Messages may be scheduled for a later delivery but at most 3 months in the future.

Add the custom parameter “scheduledTime” with the value as the date that the message should be sent. The date should be formatted according to RFC3339.

Example

 

Obfuscation

With obfuscation you can define if certain data should not be stored in the platform*.

To use obfuscation, you need to add one of these customParameters on the request object, depending on the need:

 

Parameter

Value

obfuscate.userData

true, this indicates that the userData should be obfuscated and the content itself will be replaced with the text OBFUSCATED.

 

obfuscate

true, this indicates that the userData should be obfuscated and the content itself will be replaced with the text OBFUSCATED.

This will also replace the destination with the countryCode and the first three digits (e.g. +4612345678 will be replaced to +46123)

 

  • Please be aware that when you use the obfuscate function, you are not able to search in message logs for destination number or message content.

Obfuscation Example

Example for “obfuscate.userData”

Example for “obfuscate”

Additional informaiton

Result Codes

Follow this link for a listing of common result codes,Result Codes SMS .

Silent Billing

To perform a Silent Billing (billing the end-user without them receiving a text message on their phone) set the customParameter "chargeOnly" to "true" (the string "true", not the Boolean true). Silent billing is only available in certain markets and is bound by additional agreements and restrictions. Your sales associate or Support will advise you if you are in doubt.

Examples

The following example shows how to send a premium (charged) message. The following message would cost 1 NOK for the end-user to receive. It is sent from Norwegian shortcode 71300 to Norwegian phonenumber 41560067 (country code +47). The delivery report is delivered to a predetermined gateId. (Delivery reports are required for charged messages. Only TON “SHORTNUMBER” is accepted for charged messages.)

 

 

Norway (Strex) only

You must also set the customParameter "authorize" to "true", and "strex.username" to your company's Strex MerchantID. On the FIRST time you bill an end-user silently, you must also set the customParameter "strex.securityLevel" to 2. On the second and subsequent requests, this parameter should not be present.

 

Supported TLS versions

From 2020-11-15 will TLS 1.2 or higher be required for all HTTPS connections.

Support for TLS 1.0 and 1.1 will be discontinued. Versions 1.0 and 1.1 of TLS are older protocols that have been deprecated and are considered as security risks in the Internet community.

CONNECT strongly recommend using HTTPS if HTTP is being used today.

HTTP is deprecated as of 2020-09-01 by CONNECT and will be removed in the future. Date for HTTP removal is not yet decided.