Skip to content

API reference

Subscription API

Subscription API allows a subscriber to register or unregister to or from an app, send subscription notification, query subscription status and query subscriber base size.

Base URL
https://api.mspace.lk
Content type
application/json;charset=utf-8
Endpoints
6
POSTsubscription/userSubscription

User Subscription

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

This service handles user subscription process(subscription/unsubscription)

Request bodyapplication/json;charset=utf-8

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_999999
password
stringRequired

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

Encoded, single value.

Example:95904999aa8edb0c038b3295fdd271de
subscriberId
stringRequired

This can be the MSISDN of the subscriber to be charged. This is a unique identifier.

tel: is for MSISDN

Subcriber: tel:94716177301

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

Only a single value can be sent per request.

Example:tel:94716177301
action
stringRequired

0 -user unsubscription

1 -user subscription

Enum:01
Example:0
Request sampleJSON
{
  "applicationId": "APP_999999",
  "password": "95904999aa8edb0c038b3295fdd271de",
  "subscriberId": "tel:94716177301",
  "action": "0"
}

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.
statusCode
stringRequired

The status code for the entire request.

Note: When the request is successful, statusCode will be S1000.

Example:S1000
statusDetail
stringRequired

Description of the status for the entire request.

S1000 - Request was successfully processed.

E1346 - Subscription request for < MSISDN > could not be processed as the subscription rate limit has been exceeded. Maximum of < MAX_SUBS_PER_WINDOW > subscription attempts allowed within < WINDOW_SECONDS > seconds. Please try again after < retryAfter > seconds.

E1347 - Subscription request for < MSISDN > could not be processed as the maximum active subscription limit of < MAX_ACTIVE_SUBS > has been reached. The subscriber must unsubscribe from an existing application before subscribing to a new one.

Note: E1346 and E1347 are returned only for subscription requests (action = 1).

Example:not registered
subscriptionStatus
stringRequired

Status of the subscription eg:UNREGISTERED,REGISTERED

Example:UNREGISTERED.
Response sample · Success200 · JSON
{
  "version": "1.0.",
  "statusCode": "S1000",
  "statusDetail": "not registered",
  "subscriptionStatus": "UNREGISTERED."
}
Response sample · E1347 - Maximum active subscription limit reached200 · JSON
{
  "version": "1.0",
  "statusCode": "E1347",
  "statusDetail": "Subscription request for tel:94716177301 could not be processed as the maximum active subscription limit of 20 has been reached. The subscriber must unsubscribe from an existing application before subscribing to a new one.",
  "subscriptionStatus": "UNREGISTERED"
}

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

POSTsubscription/baseSize

Base Size

https://api.mspace.lk/subscription/query-base

This service returns the number of registered subscribers

Request bodyapplication/json;charset=utf-8

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_000201
password
stringRequired

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

Encoded, single value.

Example:39a8d1cb245029d0560619a2b388669c
Request sampleJSON
{
  "applicationId": "APP_000201",
  "password": "39a8d1cb245029d0560619a2b388669c"
}

Response200 successapplication/json;charset=utf-8

baseSize
stringRequired

Number of registered users

Example:0
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.
statusCode
stringRequired

The status code for the entire request.

Example:S1000
statusDetail
stringRequired

Description of the status for the entire request.

Example:Success.
Response sample200 · JSON
{
  "baseSize": "0",
  "version": "1.0.",
  "statusCode": "S1000",
  "statusDetail": "Success."
}

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

POSTsubscription/subscriberStatus

Subscriber Status

https://api.mspace.lk/subscription/getStatus

This service returns the user subscription status(unregistered,registered)

Request bodyapplication/json;charset=utf-8

applicationId
stringRequired

Unique identification of the application within the platform

Example:APP_999999
password
stringRequired

Password given when provisioning the application

Example:95904999aa8edb0c038b3295fdd271de
subscriberId
stringRequired

This is the MSISDN of the subscriber to be charged

Example:tel:94716177301
Request sampleJSON
{
  "applicationId": "APP_999999",
  "password": "95904999aa8edb0c038b3295fdd271de",
  "subscriberId": "tel:94716177301"
}

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.
statusCode
stringRequired

The status code for the entire request.

Example:S1000
statusDetail
stringRequired

Description of the status for the entire request.

Example:Request was successfully processed
subscriptionStatus
stringRequired

Status of the subscription INITIAL,REG_PENDING,TRIAL,

REGISTERED,UNREGISTERED and TEMPORARY_BLOCKED

Example:UNREGISTERED.
Response sample200 · JSON
{
  "version": "1.0.",
  "statusCode": "S1000",
  "statusDetail": "Request was successfully processed",
  "subscriptionStatus": "UNREGISTERED."
}

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

POSTsubscription/getSubscriberChargingInfo

Get Subscriber Charging Info

https://api.mspace.lk/subscription/getSubscriberChargingInfo

Request bodyapplication/json;charset=utf-8

applicationId
stringRequired

Unique identification of the application within the platform

Example:APP_102672
password
stringRequired

Password given when provisioning the application

Example:cf2b9e361c13bc54b86d3c8180b0582fd
subscriberIds
stringOptional

MSISDNs of the list of subscribers. Eg: [tel: 94712342345, tel: 94712678845, tel:9471982563]

If the application accepts masked numbers, list of

masked numbers must be communicated in this parameter

List can contain maximum of 10 MSISDNs per request

Example:["tel: 94712342345","tel: 94712678845","tel: 9471982563"]
Request sampleJSON
{
  "applicationId": "APP_102672",
  "password": "cf2b9e361c13bc54b86d3c8180b0582fd",
  "subscriberIds": [
    "tel: 94712342345",
    "tel: 94712678845",
    "tel: 9471982563"
  ]
}

Response200 successapplication/json;charset=utf-8

version
stringRequired
Example:1.0
destinationResponses
array of objectsOptional
Array item fields
subscriberId
stringRequired

MSISDN of the subscriber.

If the application accepts masked numbers,

list of masked numbers must be communicated in this parameter

THIS IS A MANDATORY FILED

Example:tel:94712342345
subscriptionStatus
stringOptional

Status of the subscription

Eg: INITIAL,

REG_PENDING, TRIAL, REGISTERED,

UNREGISTERED and TEMPORARY_BLOCKED

Example:REGISTERED
lastChargedDate
stringOptional

The successful last charged date of the subscriber

in the format of YYYY-MM-DD hh:mm:ss

Example:2020-01-23 22:03:22
lastChargedAmount
stringOptional

The successful last charged amount for the

subscriber with the currency code

Example:30.00 LKR
numberType
stringOptional

Denotes whether the subscriber is prepaid or postpaid

Example:postpaid
statusCode
stringOptional

Success or error code for each subscriber and for

the entire request

Example:S1000
statusDetail
stringOptional
Example:Request was successfully processes
statusCode
stringRequired

The status code for the entire request

Example:S1000
statusDetail
stringRequired

Below table provides information on different subscription statuses returned

by the getSubscriptionChargingInfo service.

INITIAL - Subscription request is sent to the system. The subscription request

might not be completed may be due to a system error. Not even the charging

call is made during this instance.

Parameters returns in response : subscriberId,subscriptionStatus,

numberType,statusCode,statusDetail

REG_PENDING - Subscription request is made and charging request is also sent

but charging is not yet success.(Eg: Charging response not yet received from the IN,

Insufficient balance)

Parameters returns in response : subscriberId,subscriptionStatus,

numberType,statusCode,statusDetail

TRIAL - Subscription request is made and the platform allows subscribers to use

the service without charging as they have a free trial period enabled.

Parameters returns in response : subscriberId,subscriptionStatus,

numberType,statusCode,statusDetail

REGISTERED - Subscription request is made, charging is successful and the

subscriber can receive the service.If the application registered to is a free

application lastChargedDate to be omitted and lastChargedAmount to be sent as

0.00 LKR

Parameters returns in response : subscriberId,subscriptionStatus,

lastChargedDate,lastChargedAmount,numberType,statusCode,statusDetail

UNREGISTERED - Subscription request is made and unsubscription is also

done by the subscriber for the particular service.If the application unregistered

from is a free application lastChargedDate to be omitted and lastChargedAmount to be

sent as 0.00 LKR

Parameters returns in response : subscriberId,subscriptionStatus, lastChargedDate,lastChargedAmount,numberType,statusCode,statusDetail

TEMPORARY_BLOCKED - Subscription request is made initial charging was

also successful and was in the registered status once but

recursive charging has failed

(Eg: Due to insufficient balance) and service is temporarily blocked for this subscriber

If the application registered to is a free

application lastChargedDate to be omitted and lastChargedAmount to be sent as 0.00 LKR

Parameters returns in response : subscriberId,subscriptionStatus,lastChargedDate,lastChargedAmount,

numberType,statusCode,statusDetail

The status detail 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 request to application <application-id>. Please use a provisioned system to send request or contact system admin to provision the new IP.

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.

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

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

E1601 - System experienced an unexpected error.

E1603 - Temporary System Error occurred while delivering your request

Example:Success.
Response sample200 · JSON
{
  "version": "1.0",
  "destinationResponses": [
    {
      "subscriberId": "tel:94712342345",
      "subscriptionStatus": "REGISTERED",
      "lastChargedDate": "2020-01-23 22:03:22",
      "lastChargedAmount": "30.00 LKR",
      "numberType": "postpaid",
      "statusCode": "S1000",
      "statusDetail": "Request was successfully processes"
    }
  ],
  "statusCode": "S1000",
  "statusDetail": "Success."
}

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

POSTsubscription/notify

Subscriber Notifications

https://api.mspace.lk/subscription/notify

This service sends notifications to the users

Request bodyapplication/json;charset=utf-8

timeStamp
stringRequired

The timestamp sent from the SMS. "yyMMddHHmm" yy – last two digits of the year (00-99) MM – month (01-12) dd – day (01-31) HH – hour (00-23) mm- minute (00-59)

Example:20120113082110
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_999999
password
stringRequired

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

Encoded, single value.

Example:95904999aa8edb0c038b3295fdd271de
subscriberId
stringRequired

This can be the MSISDN of the subscriber to be charged. This is a unique identifier.

tel:94716177301 is for MSISDN

Subcriber: tel:94716177301

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

Only a single value can be sent per request.

Example:tel:94716177301
frequency
stringRequired

Frequency of notifications being sent

Enum:dailyweeklymonthlyyearly
Example:monthly
status
stringRequired

Status of the subscription eg:UNREGISTERED,REGISTERED

Example:REGISTERED.
Request sampleJSON
{
  "timeStamp": "20120113082110",
  "version": "1.0",
  "applicationId": "APP_999999",
  "password": "95904999aa8edb0c038b3295fdd271de",
  "subscriberId": "tel:94716177301",
  "frequency": "monthly",
  "status": "REGISTERED."
}

Response200 successapplication/json;charset=utf-8

statusCode
stringRequired

The status code for the entire request.

Example:S1000
statusDetail
stringRequired

Description of the status for the entire request.

Example:Request was successfully processed
Response sample200 · JSON
{
  "statusCode": "S1000",
  "statusDetail": "Request was successfully processed"
}

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

POSTsubscription/getSubscriberList

Subscriber List

https://api.mspace.lk/subscription/getSubscriberList

This service provides an opportunity for the developers to retrieve subscriber list. This API allows the developer to stay updated with the subscription notifications which he/she has missed receiving.

Request bodyapplication/json;charset=utf-8

applicationId
stringRequired

Unique identification of the application within the platform

Example:APP_102672
password
stringRequired

Password given when provisioning the application

Example:cf2b9e361c13bc54b86d3c8180b0582fd
version
stringOptional

API version

Example:1.0
requestPage
IntegerRequired

The specific page number from a list of pages containing subscription notifications.

Example:2
Request sampleJSON
{
  "applicationId": "APP_102672",
  "password": "cf2b9e361c13bc54b86d3c8180b0582fd",
  "version": "1.0",
  "requestPage": 2
}

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
statusCode
stringRequired

Succes or error code for each subscriber and for the entire request

Enum:S1000S1001E1100E1102E1103E1104E1105E1106E1107
Example:S1000
statusDetail
stringRequired

Description corresponding to the status code

S1000 Request Was Successfully Processed.

S1001 No Subscribers Found

E1100 System Experienced an Unexpected Error.

E1102 Service Provider Is Not In Active Status.

E1103 Request Parameters are Invalid. Refer the API Documentation

E1104 Application is Not in Active or Limited Production Status.

E1105 TPS Exceeded

E1106 Invalid Request Page, Page Number Should Be 1 Or Greater

E1107 Request Is Invalid.

Refer The API Documentation For The Mandatory Fields And Correct Format Of The Request.

Example:Request was successfully processed
nextPageNumber
IntegerRequired

Display the next page number available. If there is no page available next, -1 will be displayed.

Example:3
moreDataAvailable
BooleanRequired

Indicates if there is more data available

Example:true
subscribers
objectOptional
Object fields
subscriberId
stringRequired

MSISDN of the subscriber

Eg: tel: 94712342345

If the application accepts masked numbers, list of masked numbers must be communicated in this parameter

Example:tel: 94712342345
subscriptionStatus
stringOptional

Status of the subscription Eg: TRIAL, REGISTERED and TEMPORARY_BLOCKED

Example:REGISTERED
lastChargedDate
stringOptional

The successful last charged date of the subscriber in the format of "YYYY-MM-DD" "hh:mm:ss"

Example:2020-01-23 22.03.22
lastChargedAmount
stringOptional

The successful last charged amount for the subscriber with the currency code

Example:30.00 LKR
Response sample200 · JSON
{
  "version": "1.0",
  "statusCode": "S1000",
  "statusDetail": "Request was successfully processed",
  "nextPageNumber": 3,
  "moreDataAvailable": "true",
  "subscribers": {
    "subscriberId": "tel: 94712342345",
    "subscriptionStatus": "REGISTERED",
    "lastChargedDate": "2020-01-23 22.03.22",
    "lastChargedAmount": "30.00 LKR"
  }
}

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