Skip to content

API reference

USSD API

USSD API allows your applications to initiate USSD sessions using a HTTP-based API. You can build USSD menu driven applications, monetize based on menu request, maintain an active session with customs etc.

Base URL
https://api.mspace.lk
Content type
application/json;charset=utf-8
Endpoints
2
POSTussd/send

Ussd Send Services

https://api.mspace.lk/ussd/send

This service is used when sending USSD messages to a mobile phone from an application.USSD send service supports only POST HTTP requests.

Request bodyapplication/json;charset=utf-8

version
stringRequired

API version shall be numbered as 1.0, 2.0 etc.

If version is specified in the request, same version must be sent in the response.

If version is not specified in the request, the latest version will be specified in the response.

Example:1.0
applicationId
stringRequired

Used to identify the application. This is a unique identifier generated while provisioning an application.

Only a single value can be sent per request.

Example:APP_000001
message
stringRequired

Content of the message sent by the application

Example:1. Press One 2. Press two 3. Press three 4. Exit
password
stringRequired

Used to authenticate the application originated message against the credentials of the service provider.

Encoded, single value.

Example:password
sessionId
stringRequired

Unique number that USSD Gateway assigns to the application for the duration of the session. This number will be maintained in all the messages throughout a single session.

Example:1330929317043
ussdOperation
stringRequired

USSD operation

mo-cont:TAP to assign for and USSD message originated from subscriber, that comes after a init

nmt-init: App to assign when a USSD session is initiated by an application

mt-cont: App to assign for any USSD message originated from application, that comes after a init

mt-fin: App to assign when session ends in final message

Data type will be string where the operation name itself will be used in the parameter value.

Enum:mo-initmo-contmt-initmt-contmt-fin
Example:mt-cont
destinationAddress
stringRequired

Destination address should be a telephone number (tel - for MSISDN)

Note : tel might be a masked number depending on the type of application

Example:tel:94702725777
encoding
stringOptional

Encoding scheme used in the message

440 - Plain ASCII characters

Enum:440
Example:440
Request sampleJSON
{
  "version": "1.0",
  "applicationId": "APP_000001",
  "message": "1. Press One\n 2. Press two\n 3. Press three\n 4. Exit\n",
  "password": "password",
  "sessionId": "1330929317043",
  "ussdOperation": "mt-cont",
  "destinationAddress": "tel:94702725777 ",
  "encoding": "440"
}

Response200 successapplication/json;charset=utf-8

version
stringRequired

API version shall be numbered as 1.0, 2.0 etc.

If version is specified in the request, same version must be sent in the response.

If version is not specified in the request, the latest version will be specified in the response.

Example:1.0
requestId
stringRequired

Uniquely identifies a request within TAP

Example:101901031657410007
timeStamp
stringRequired

Processed timestamp

Example:20190103165801
statusCode
stringRequired

The status code for the entire request

Enum:S1000E1303E1308E1309E1312E1313E1315E1317E1318E1319E1325E1334E1341E1342E1343E1601E1603
Example:S1000
statusDetail
stringRequired

Description of the status for the entire request.

S1000 - Process completed successfully for all the available destination numbers.

E1303 - IP address from which this request originated is not provisioned to send requests to application <application-id>. Please use a provisioned system to send requests or contact system admin to provision the new IP.

E1308 - Permanent charging error due to<specify_reason E.g., Insufficient Balance>.

E1309 - Requested SMS service is not allowed for this Application. Please check the issue with Idea Mart system administrator.

E1312 - Request is invalid. <specify_the_reason> Refer the TAP NBL API Developer Guide for the mandatory fields and correct format of the request.

E1313 - Authentication failed. No such active application with applicationId <application-id>, or no active service provider or the given password in the request is invalid.

E1315 - Cannot find the requested service SMS or it is not active.

E1317 - < MSISDN > in request is invalid or not allowed.

E1318 - Transaction limit per second has exceeded. Please throttle requests not to exceed the transaction limit. Contact TAP admin to increase the traffic limit.

E1319 - Transaction limit for today has exceeded. Please try again tomorrow or contact TAP admin to increase the transaction per day limit.

E1325 - Format of the address is invalid. Expected format is tel:94716177301.

E1334 - SMS sent to < application name > application could not be processed as the message length is too long. Maximum message length allowed is < specify_max_limit >.

E1341 - Request failed.An error occurred while sending the request for all the destinations.

E1342 - MSISDN is black listed. Not authorized to use the application <application_name>.

E1343 - MSISDN is not white listed. Only white list numbers are allowed to send messages at this state.

E1601 - System experienced an unexpected error.

E1603 - Temporary system error occurred while delivering your request

Example:Success.
Response sample200 · JSON
{
  "version": "1.0",
  "requestId": "101901031657410007",
  "timeStamp": "20190103165801",
  "statusCode": "S1000",
  "statusDetail": "Success."
}

Code samples (Java, PHP, javaScript, .net): coming soon

POSTussd/receive

Ussd Receive Services

https://api.mspace.lk/ussd/receive

This service allows TAP to deliver MO messages to the application using HTTP – based API. The flow of messages is initiated by a MO request sent to an application,TAP will deliver the message to the application as an acknowledgement. Hence it could be either request-response exchange or a request-exception exchange.

Receive USSD request is a MO message which will be sent to the application through mSpace as a delivery request.

Request bodyapplication/json;charset=utf-8

version
stringRequired

API version shall be numbered as 1.0, 2.0 etc.

If version is specified in the request, same version must be sent in the response.

If version is not specified in the request, the latest version will be specified in the response.

Example:1.0
applicationId
stringRequired

Used to identify the application. This is a unique identifier generated while provisioning an application.

Only a single value can be sent per request.

Example:APP_000029
message
stringRequired

Content of the message sent by the user

Example:*141#
requestId
stringRequired

Uniquely identifies a request within TAP

Example:1330933229901
sessionId
stringRequired

Unique number that USSD Gateway assigns to the application for the duration of the session. This number will be maintained in all the messages throughout a single session.

Example:1330929317043
ussdOperation
stringRequired

USSD operation

mo-cont:TAP to assign for and USSD message originated from subscriber, that comes after a init

mt-init: App to assign when a USSD session is initiated by an application

mt-cont: App to assign for any USSD message originated from application, that comes after a init

mt-fin: App to assign when session ends in final message

Enum:mo-initmo-contmt-initmt-contmt-fin
Example:mt-cont
sourceAddress
stringRequired

Address of the source.

sourceAddress:tel:94702725777

at least one will be specified

Example:tel:94702725777
vlrAddress
stringOptional

VLR(Visitor Location Register) address of the sender

Example:tel:94702725777
encoding
stringRequired

Encoding scheme used in the message

440 - Plain ASCII characters

Enum:440
Example:440
Request sampleJSON
{
  "version": "1.0",
  "applicationId": "APP_000029",
  "message": "*141#",
  "requestId": "1330933229901",
  "sessionId": "1330929317043",
  "ussdOperation": "mt-cont",
  "sourceAddress": "tel:94702725777",
  "vlrAddress": "tel:94702725777",
  "encoding": "440"
}

Response200 successapplication/json;charset=utf-8

statusCode
stringRequired

The status code for the entire request

Enum:S1000E1303E1308E1309E1312E1313E1315E1317E1318E1319E1325E1334E1341E1342E1343E1601E1603
Example:S1000
statusDetail
stringRequired

Description of the status for the entire request.

S1000 - Process completed successfully for all the available destination numbers.

E1303 - IP address from which this request originated is not provisioned to send requests to application <application-id>. Please use a provisioned system to send requests or contact system admin to provision the new IP.

E1308 - Permanent charging error due to<specify_reason E.g., Insufficient Balance>.

E1309 - Requested SMS service is not allowed for this Application. Please check the issue with Idea Mart system administrator.

E1312 - Request is invalid. <specify_the_reason> Refer the TAP NBL API Developer Guide for the mandatory fields and correct format of the request.

E1313 - Authentication failed. No such active application with applicationId <application-id>, or no active service provider or the given password in the request is invalid.

E1315 - Cannot find the requested service SMS or it is not active.

E1317 - < MSISDN > in request is invalid or not allowed.

E1318 - Transaction limit per second has exceeded. Please throttle requests not to exceed the transaction limit. Contact TAP admin to increase the traffic limit.

E1319 - Transaction limit for today has exceeded. Please try again tomorrow or contact TAP admin to increase the transaction per day limit.

E1325 - Format of the address is invalid. Expected format is tel:94716177301.

E1334 - SMS sent to < application name > application could not be processed as the message length is too long. Maximum message length allowed is < specify_max_limit >.

E1341 - Request failed.An error occurred while sending the request for all the destinations.

E1342 - MSISDN is black listed. Not authorized to use the application <application_name>.

E1343 - MSISDN is not white listed. Only white list numbers are allowed to send messages at this state.

E1601 - System experienced an unexpected error.

E1603 - Temporary system error occurred while delivering your request

Example:Success
Response sample200 · JSON
{
  "statusCode": "S1000",
  "statusDetail": "Success"
}

Code samples (Java, PHP, javaScript, .net): coming soon