Tiara Gateway is a fast, simple, secure and scalable enterprise messaging Gateway that simplifies how organizations connect to their customers via Short Message Service (SMS) and Unstructured Supplementary Service Data (USSD).
Multiple enterprise applications or systems can connect to the gateway and the gateway can reliably route SMS traffic to multiple mobile network operators.
USSD is a global system used by mobile network operators to deliver interactive, session-based communication. Our gateway allows users to send text-based requests from their mobile phones where we reliably route this request to the connected USSD client application. Additionally, we route back the responses from the client application to the end user.
The purpose of this document is to provide documentation of the HTTP Application Programming Interface (API ) that allows 3rd party applications to connect to the Tiara SMS Gateway for the purpose of sending out messages and receiving delivery receipts in addition to receiving USSD requests from end users and forwarding USSD responses to the end user.
The Send SMS API allows applications to send SMS messages to mobile subscribers (mobile users). This API is designed to help organizations communicate with their customers via SMS e.g. an ecommerce app may send a payment confirmation SMS.
The API allows you to send SMS requests from your application (e.g. your e-commerce app) to the messaging gateway. For each request sent from your application, the messaging gateway sends a response back to your application indicating whether the message was submitted to the mobile operator successfully or not.
The API provides a unique message ID for each SMS sent, enabling applications to track whether messages are successfully delivered to users’ mobile devices.
Once a message is delivered to a mobile device, a delivery receipt confirmation can be sent back to the application, ensuring that communication with users is effective and reliable.
The diagram below shows how an SMS message is relayed from your application to the mobile operator (e.g. Safaricom Kenya or Vodafone Tanzania) through the Tiara messaging gateway. The diagram also illustrates how delivery receipts are sent from the mobile operator to your application through the SMS gateway.
Your application sends an HTTP POST request to the Tiara SMS Gateway. The request is in JSON format. The request structure is specified below.
You require the following header details to use the SMS API.
Requirement | Description |
---|---|
Endpoint | To be provided at the time of integration. |
Content Type | Content-Type: application/json |
Authorization | Authorization: Bearer (API Key) |
Data Interchange Format | JSON |
HTTP Method | POST |
The table below specifies the parameters required in the send single sms operation.
Parameter | Type | Description | Comments |
---|---|---|---|
from | String | Sender ID or short code used in sending the SMS to the mobile phone. | Mandatory E.g. TIARA |
to | String | The recipient’s mobile number. | Mandatory E.g. 2547XXXXXXXX |
message | String | The SMS content. | Mandatory E.g. Test SMS |
linkId | String | Link ID for conversational ID for interactive SMS (mobile phone initiates the conversation by sending a message to a short code). | Optional E.g. 00182816930079890584 |
refId | String | refId is for the external system ID. This is the reference ID from the client’s system. | Optional E.g. 09wiwu088e |
messageType | String | This defines the type of message to be sent. Each message type is assigned a specific numeric code as defined in the message types below. This is an optional field. | Optional E.g. “1” for sms |
{
"from": "TIARA",
"to": "2547XXXXXXXX",
"message": "Test SMS",
"refId": "09wiwu088e"
}
curl --location 'https://api.tiaraconnect.io/api/messaging/sendsms' \
--header 'Authorization: Bearer <<API-KEY>>' \
--header 'Content-Type: application/json' \
--data '{
"from": "TIARA",
"to": "2547XXXXXXXX",
"message": "Test SMS",
"refId": "09wiwu088e"
}'
You require the following details to use the SMS API.
Message Type | Description |
---|---|
1 | Standard SMS |
2 | Flash SMS (not supported by all telcos) |
3 | |
4 | Reserved |
5 | USSD (not supported in this API) |
The SMS Gateway responds with a unique message id in the HTTP Response. The id uniquely identifies the message within the gateway. The same message id is used in the delivery receipt callback described in step 4 below. More information about the HTTP response is specified below.
The table below specifies the parameters specified in the send SMS response.
Parameter | Type | Description | Comments |
---|---|---|---|
status | String | Message processing status | Possible values:
|
statusCode | String | Processing status code | Possible values:
|
desc | String | Processing status description | E.g. Invalid request. The parameter ‘to’ cannot be empty. |
to | String | The recipient’s mobile number. | |
msgId | String | Unique message ID for the request. This message id is used in the callback request. | E.g. 0bc5be98-5322-4cf3-ac02-303165997da5 |
cost | String | SMS cost | E.g. KSH 0.6 |
balance | String | Remaining balance after sending the message | E.g. KSH 3142.61 |
mcc | String | Country Code | E.g. 639 for Kenya |
mnc | String | Network code | E.g. 02 for Safaricom |
Sample JSON response: for HTTP code 200
{
"cost": "KES 0.6",
"mnc": "02",
"balance": "KES 3137.5598",
"msgId: "0bc5be98-5322-4cf3-ac02-303165997da5",
"to": "2547XXXXXXXX",
"mcc": "639",
"desc": "Success",
"status": "SUCCESS",
"statusCode": "0"
}
Sample JSON response for errors.
{
"timestamp": "2021-01-01T10:20:00.335+00:00",
"status": "403",
"error": "Forbidden",
"message: "",
"path": "/api/messaging/sendsms"
}
Tiara SMS Gateway forwards the message to the mobile operator and eventually, the message is forwarded to the mobile phone (mobile subscriber).
NOTE: The request structure is not necessary for developers.
Once the mobile phone receives the sent message, the phone generates a delivery receipt which is sent back to the mobile operator and the mobile operator forwards the same receipt to the Tiara Messaging Gateway.
NOTE: The response structure is not necessary for developers.
Upon receiving the delivery receipt from the mobile operator, the Messaging Gateway forwards the delivery receipt to your application via an HTTP callback URL. The delivery receipt callback sent to your application is an HTTP POST request with a JSON body with the parameters specified below.
The delivery receipt callback response sent to your application is an HTTP request with the following header parameters set in the request.
Requirement | Description |
---|---|
Endpoint | Endpoint to your application |
Content Type | Supported HTTP content type. Content-Type: application/json |
Data Interchange Format | JSON |
HTTP Method | POST |
The table below specifies the parameters sent to your application in the delivery receipt callback request.
Parameter | Type | Description | Comments |
---|---|---|---|
msgId | String | The unique message ID is returned in the Send SMS response. See Step 1(b) Send SMS Response | Mandatory E.g. 0bc5be98-5322-4cf3-ac02-303165997da5 |
from | String | The recipient's mobile number. | Optional e.g, 2547XXXXXXXX |
to | String | The sender ID or the shortcode used in Send SMS. | Optional E.g. TIARA |
refId | String | The client's reference id. | Mandatory |
status | String | Delivery receipt status. Specification of delivery status is provided in the section below. | Mandatory E.g. DeliveredToTerminal or DELIVRD |
statusReason | String | Description of the status. | Optional E.g. DeliveredToTerminal |
deliveryTime | String | The time the delivery receipt was received on the gateway. | Mandatory e.g, 2019-02-05 18:27:39.986 |
Sample JSON Delivery receipt Payload sent to your application:
{
"msgId": "0bc5be98-5322-4cf3-ac02-303165997da5",
"from": "2547XXXXXXXX",
"to": "TIARA",
"refId": "TIARA"
"status": "DeliveredToTerminal",
"statusReason": "DeliveredToTerminal",
"deliveryTime": "2019-02-05 18:27:39.878",
}
curl --location 'https://webhook.site/268e95a8-8902-4c59-b7f4-5e1f350e60ab' \
--header 'Content-Type: application/json' \
--data '{
"msgId": "0bc5be98-5322-4cf3-ac02-303165997da5",
"from": "2547XXXXXXXX",
"to": "TIARA",
"refId": "TIARA"
"status": "DeliveredToTerminal",
"statusReason": "DeliveredToTerminal",
"deliveryTime": "2019-02-05 18:27:39.878",
}'
The table below specifies the list of delivery statuses that will be visible on the SMS portal or contained in the callback payload.
Delivery Status | Description | Comments |
---|---|---|
DeliveredToTerminal | SMS was successfully delivered to the handset through an SDP connection. | SDP (Service delivery platform) connection is via HTTP protocol E.g Safaricom in Kenya offers this to most partners. |
DELIVRD | SMS was successfully delivered to the handset through an SMPP connection. | SMPP is the de facto standard/protocol in SMS messaging |
SenderName Blacklisted | SMS was not delivered to the handset as a result of the customer's OPT-OUT | Customers can opt out of promotional messages or from receiving SMS through specific Sender IDs. |
UNDELIV | SMS undelivered to the handset for several reasons | Caused by handset-related issues or Mobile Network issues. Requires escalations to the telco to get an exact reason. |
EXPIRED | SMS submission to the handset failed after a given period | Mobile Operators have a retry duration beyond which an SMS message will no longer be submitted. |
DeliveryImpossible | SMS could not be delivered for several reasons | Mostly caused by network issues at the Mobile Operator level e.g. Absent Subscriber details. |
REJECTD | SMS unsuccessfully submitted to Mobile Operator | Internal processing checks may cause sms to be rejected e.g. unallowed content is blocked/rejected |
Your application can send multiple SMS messages by making an HTTP POST request to the Gateway. The Gateway supports two formats for sending a batch of messages:
Choose either format based on your application's needs, and the Gateway will handle the batch accordingly.
The diagram below shows how batch messages are relayed from your application to the mobile operator through our gateway.
Your application sends an HTTP POST request in JSON format to the Tiara Messaging Gateway to send multiple SMS messages. There are two options for structuring the batch request:
The request is in JSON format. The request structure is specified below.
You require the following header details to use the SMS Batch API.
Requirement | Description |
---|---|
Endpoint | To be provided at the time of integration. |
Content Type | Supported HTTP content type. Content-Type: application/json |
Authorization | The operation requires an API key to be specified as part of the HTTP header: Authorization: Bearer (API Key) The API key will be provided at the time of creating the application. |
Data Interchange Format | JSON |
HTTP Method | POST |
The table below specifies the parameters required in the send batch sms operation.
Parameter | Type | Description | Comments |
---|---|---|---|
from | String | Sender ID or short code used in sending the SMS to the mobile phone. | Mandatory E.g. TIARA |
to | String | The recipient’s mobile number. | Mandatory E.g. 2547XXXXXXXX |
message | String | The SMS content. | Mandatory E.g. Test SMS |
linkId | String | Link ID for conversational ID for interactive SMS (mobile phone initiates the conversation by sending a message to a short code). | Optional E.g. 00182816930079890584 |
refId | String | refId is for the external system ID. This is the reference ID from the client’s system. | Optional E.g. 09wiwu088e |
messageType | String | This specifies the message type. | Optional E.g. “2” for sms |
Send an array of JSON objects, with each object containing an individual phone number.
[
{
"to": "254713XXXXXX",
"from": "TIARA",
"message": "Testing1",
"refId": "refIdx"
},
{
"to": "254713XXXXXX",
"from": "TIARA",
"message": "Testing2",
"refId": "refIdx"
}
]
curl --location 'https://api.tiaraconnect.io/api/messaging/sendbatch' \
--header 'Authorization: Bearer <<API-KEY>>' \
--header 'Content-Type: application/json' \
--data '[
{
"to": "254713XXXXXX",
"from": "TIARA",
"message": "Testing1",
"refId": "refIdx"
},
{
"to": "254713XXXXXX",
"from": "TIARA",
"message": "Testing2",
"refId": "refIdx"
}
]'
The SMS Gateway responds with a unique message ID in each HTTP response in the response list. These IDs uniquely identify each message within the gateway and will also be used in the delivery receipt callback in Step 4. More details on the HTTP response is specified below.
Parameter | Type | Description | Comments |
---|---|---|---|
status | String | Message processing status | Possible values:
|
statusCode | String | Processing status code | Possible values:
|
desc | String | Processing status description | E.g. Invalid request. The parameter ‘to’ cannot be empty. |
to | String | The recipient’s mobile number. | |
msgId | String | Unique message ID for the request. This message id is used in the callback request. | E.g. E.g. f25aa605-e789-4e1c-b64d-b35e29b19b87 |
cost | String | SMS cost | E.g. KSH 0.9999997 |
balance | String | Remaining balance after sending the message | E.g. KSH 3142.61 |
mcc | String | Country Code | E.g. 639 for Kenya |
mnc | String | Network code | E.g. 02 for Safaricom |
Sample JSON response: for HTTP code 200
[
{
"cost": "KES 0.0075",
"mnc": "02",
"balance": "KES 3122.1125",
"msgId: "f25aa605-e789-4e1c-b64d-b35e29b19b87"
"to": "2547XXXXXXXX"
"mcc": "639"
"desc": "Success"
"status": "SUCCESS"
"statusCode": "0"
},
{
"cost": "KES 0.0075",
"mnc": "02",
"balance": "KES 3122.105",
"msgId: "4bf79d12-0bf0-4e4f-8ced-d714c6c0f331"
"to": "2547XXXXXXXX"
"mcc": "639"
"desc": "Success"
"status": "SUCCESS"
"statusCode": "0"
},
]
Sample JSON response for errors.
[
{
"timestamp": "2021-05-28T10:20:00.335+00:00",
"status": "403",
"error": "Forbidden",
"message: "",
"path": "send-batch-api"
},
{
"timestamp": "2021-05-28T10:20:00.335+00:00",
"status": "403",
"error": "Forbidden",
"message: "",
"path": "send-batch-api"
}
]
Tiara SMS Gateway forwards the batch messages to the mobile operator and eventually, each message is forwarded to the respective mobile phone (mobile subscriber).
NOTE: The request structure is not necessary for developers.
Once the mobile phone receives the sent message, the phone generates a delivery receipt which is sent back to the mobile operator and the mobile operator forwards the delivery receipt to our SMS Gateway.
NOTE: The response structure is not necessary for developers.
Upon receiving the delivery receipt from the mobile operator, the Messaging Gateway forwards the delivery receipt to your application via a HTTP callback URL. The delivery receipt callback sent to your application is a HTTP POST request.
NOTE: The same parameters used in the Send SMS API to forward the delivery receipt to your application via HTTP Callback URL also apply here.
For more information, refer to section Step 4: Forward the delivery receipt via HTTP Callback URL in the send sms API.
When a mobile phone user sends a message to a shortcode, this message is referred to as a Mobile-Originated (MO) message — meaning it originates from the mobile user. The Tiara messaging gateway then forwards this MO message to the client’s application via an HTTP callback URL. This callback URL to your application is provided and configured during the integration process, allowing the client’s application to receive and process incoming messages in real-time.
By using this setup, the client’s application can immediately process incoming messages, enabling real-time responses or further actions based on the content of each MO message. This mechanism is particularly useful for applications that require instant user interaction, such as surveys and customer support interactions.
Below is a use case to illustrate how forwarding MO works:
The diagram below shows how an MO is relayed from the mobile operator through the Tiara messaging gateway to your application.
A user sends an SMS from their mobile phone to a specific shortcode associated with a service. This message, known as a Mobile-Originated (MO) message, is received by the mobile operator, who then forwards the user-initiated message to the messaging gateway for processing.
NOTE: The request structure is not necessary for developers.
The messaging gateway then forwards the message to your application via a HTTP callback URL. The received message (MO) callback sent to your application is a HTTP POST request with a JSON body with the parameters specified below.
Requirement | Description |
---|---|
Endpoint | Endpoint to your application |
Content Type | Supported HTTP content type. Content-Type: application/json |
Data Interchange Format | JSON |
HTTP Method | POST |
The table below specifies the parameters sent to your application in the received message (MO) callback request.
Parameter | Type | Description | Comments |
---|---|---|---|
msgId | String | The unique message ID is generated by the messaging gateway. | Mandatory E.g. 234223 |
from | String | The sender’s mobile number. | Mandatory E.g. 2547XXXXXXXX |
to | String | The sender id or the shortcode that receives the requests. | Mandatory E.g. TIARA |
refId | String | The client’s reference ID. | Optional E.g. 09wiwu088e |
message | String | The message received from the telco. | Mandatory E.g. Hello |
linkId | String | For the SMPP connection, the value will be smpp. For HTTP connection, value is null. | Optional E.g. smpp |
receiveTime | String | The time the mo message was received from the telco. | Optional E.g. 2019-02-05 18:27:39.878 |
Sample JSON MO Payload sent to your application:
{
"msgId: "234223",
"from": "2547XXXXXXXX",
"to": "TIARA",
"refId": "null",
"message": "Hello",
"linkId": "smpp",
"receiveTime": "2019-02-05 18:27:39.878"
}
curl --location 'https://webhook.site/268e95a8-8902-4c59-b7f4-5e1f350e60ab' \
--header 'Content-Type: application/json' \
--data '{
"msgId: "234223",
"from": "2547XXXXXXXX",
"to": "TIARA",
"refId": "null",
"message": "Hello",
"linkId": "smpp",
"receiveTime": "2019-02-05 18:27:39.878"
}'
The Survey Trigger API allows an external system to connect with the Tiara messaging gateway and automatically initiate a predefined survey to users who interact with an external system.
When a user interacts with the external system, this API triggers a survey to be sent to the user’s mobile phone, enabling immediate and seamless feedback collection.
To enable this, you will need to create a survey on our messaging gateway system which will be triggered to your customers once they interact with your system.
This integration is highly useful in touchpoint NPS (Net Promoter Score), to automatically survey customers and get their reviews after they interact with the client system. The API in addition can send the customer response via email back to the client system.
Use case: Ticketing system for a bank.
The diagram below shows the flow from when a mobile user interacts with an external system and a survey is triggered to them and they send their responses.
A mobile user can interact with an external system e.g. the ticketing system in a bank by performing an action on the external 3rd party system.
The user interaction causes your application to send a trigger survey request to the Tiara messaging gateway. Your application sends an HTTP POST request to the Tiara SMS Gateway. The request is in JSON format. The request structure is specified below.
Requirement | Description |
---|---|
Endpoint | Endpoint to your application |
Content Type | Supported HTTP content type. Content-Type: application/json |
Data Interchange Format | JSON |
HTTP Method | POST |
The table below specifies the parameters required to send a survey trigger request to the Messaging gateway.
Parameter | Type | Description | Comments |
---|---|---|---|
msisdn | String | The customer's mobile number | Mandatory E.g. 2547XXXXXXXX |
srcSystem | String | The name of the external system. | Mandatory E.g. REGONLINE |
dataFeed | String | The name of the survey to be triggered | Mandatory E.g. tiara-poller-dlr |
fileName | String | The survey Id | Mandatory E.g. 555 |
{
"msisd": "2547XXXXXXXX",
"srcSystem": "REGONLINE",
"dataFeed": "tiara-poller-dlr"
"fileName": "55"
}
curl --location 'https://api.tiaraconnect.io/engagements/trigger' \
--header 'Authorization: Bearer <<API-KEY>>' \
--header 'Content-Type: application/json' \
--data '{
"msisd": "2547XXXXXXXX",
"srcSystem": "REGONLINE",
"dataFeed": "tiara-poller-dlr"
"fileName": "55"
}'
Upon receiving the trigger request, the API initiates a predefined survey (created in the messaging gateway system) to the mobile operator.
NOTE: The request structure is not necessary for developers.
The mobile operator then forwards the SMS to the mobile subscriber's phone.
NOTE: The request structure is not necessary for developers.
The user then responds to the survey. The reply is sent to the mobile operator.
NOTE: The response structure is not necessary for developers.
The mobile operator then forwards the user input (MO) to the messaging gateway.
NOTE: The response structure is not necessary for developers.
The Tiara messaging gateway then forwards the user input to the client application via a HTTP callback URL. In addition, the trigger API sends the customer’s survey response to an email address specified by the client.
NOTE: The same parameters used in the Forwarding MO API to forward the Mobile Originated (MO) message (user’s response) to the client application via HTTP Callback URL also apply here.
For more information, refer to section Step 2 Forward received message (MO) via HTTP Callback URL in the forwarding MO API.
USSD is a global system used by mobile network operators to deliver interactive, session-based communication. Our gateway allows users to send text-based menu requests from their mobile phones where we reliably route this request to the connected USSD enterprise application allowing organizations to connect to their customers via Unstructured Supplementary Service Data (USSD).
Additionally, we route back the responses (menus) from the enterprise application to the end user. The messaging gateway allows 3rd party applications to connect to the Tiara USSD Gateway for the purpose of receiving USSD requests from end users and forwarding USSD responses to the end user. This is done via an HTTP endpoint that is exposed by the 3rd party USSD app developer.
The mobile subscriber can establish a USSD session by dialing a USSD code. Your application can then respond with the USSD menu to the mobile subscriber through the USSD gateway.
The diagram below shows how a USSD message is relayed from your application to the mobile subscriber through the sms gateway.
A mobile subscriber initiates a session by dialing a specific USSD code, such as *123*XXX#. This USSD code is a predefined code that triggers the USSD session, enabling communication between the subscriber’s mobile device and the service provider. Once the USSD code is dialed, a request is sent to the mobile operator.
Once the mobile operator receives the request, the mobile operator makes an HTTP request to the Tiara USSD Gateway.
NOTE: The request structure is not necessary for developers.
The USSD gateway validates and processes the request forwarded by the mobile operator (telco). It then determines the appropriate endpoint for your application. The USSD Gateway makes an HTTP POST request to your USSD application via a HTTP URL. This request is URL encoded , containing key information like the sessionId, subscriber details and user input. The request structure for this POST request sent to your application is specified below.
The USSD request sent to your application is a HTTP request with the following header parameters set in the request.
Requirement | Description |
---|---|
Client Application endpoint | Endpoint to your application |
Content Type | Supported HTTP content type. Content-Type: application/x-www-form-urlencoded |
HTTP Method | POST |
Data Interchange Format | Url encoded body |
The table below specifies the parameters in the USSD request sent to your application.
Parameter | Type | Description | Comments |
---|---|---|---|
msisdn | String | The recipient’s mobile number | Mandatory E.g. 2547XXXXXXXX |
sessionId | String | USSD session ID. Session ID will be the same across all the sessions. | Mandatory E.g. 149505148 |
input | String | This is the input the user replied/entered. The first response will be an empty string, this signifies the start of a new session. The subsequent values concatenate all the user input within the session with an asterisk (*) until the session ends. | Mandatory E.g. 1*2 |
serviceCode | String | USSD code that was dialed by the user | Optional (for new session) E.g. *123*12# |
countryCode | String | User Country Dialling Code | Mandatory E.g. 254 |
network | String | Name of the mobile operator | Mandatory E.g. Safaricom KE |
The request is URL Encoded:
msisdn=2547XXXXXXXX&sessionId=149505148&input=1&serviceCode=*123*12#&countryCode=254&network=Safaricom+KE
curl --location 'https://webhook.site/268e95a8-8902-4c59-b7f4-5e1f350e60ab' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'msisdn=2547XXXXXXXX' \
--data-urlencode 'sessionId=123456' \
--data-urlencode 'serviceCode=*123*XXX#' \
--data-urlencode 'input=2' \
Your application responds with the appropriate USSD menu response, which could include a menu of options or instructions for the subscriber. The response is sent back to the USSD gateway via the HTTP response from the 3rd party USSD app. The response structure with the USSD menu is specified below.
The response should be text starting with either CON or END:
CON Welcome to ABC\n Please enter your name
END Thank you for registering
NOTE: Session management will be done by the 3rd party USSD application.
The Tiara USSD Gateway forwards the USSD menu response to the mobile operator.
NOTE: The request structure is not necessary for developers.
The mobile operator then forwards the menu to the end user (mobile subscriber/phone). The mobile subscriber sees the USSD menu on their screen and can interact with it.
The process continues with each response from the subscriber triggering a new request and the menu response cycle until the session is completed or terminated by the subscriber.
For any additional queries and clarification on the API, please send an email to support@tiaraconnect.io and we will be happy to help you.