NAV -image
php bash python

Introduction

Welcome to the SMS Niaga API Reference!

The REST API communicates exclusively in JSON over SSL (HTTPS). Request and response data are JSON formatted using UTF-8 encoding and URL encoded values. The only requirement to use our API is to create an account on our portal.

It is recommended that you use the media type designation of application/json. All endpoint URLs begin with a domain name. Currently we have the following API node:

manage.smsniaga.com

Authentication

To authenticate requests, include an Authorization header with the value "Bearer {your-token}".

You can retrieve your token by visiting your dashboard and clicking Profile > API Token.

Balance

For credit balance related endpoint. Balance will be in monetary value (Malaysian Ringgit).

GET /api/balance

Check current user balance via API.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://manage.smsniaga.com/api/balance',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET \
    -G "https://manage.smsniaga.com/api/balance" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/balance'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):

{
    "balance": {
        "cents": 92000,
        "human": "RM9.20",
        "currency": "MYR"
    }
}

Request

GET api/balance

SMS (MT)

For sending SMS message related endpoint. MT stand for mobile terminated. This means that MT message is being terminated on the mobile phone, or to put it simply, this is a message sent from SMS system to subscriber’s mobile phone.

POST /api/send

This endpoint allow you to send SMS by using our API with supplied token.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://manage.smsniaga.com/api/send',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
        'json' => [
            'body' => 'RM0.00 WEB IMPIAN: Your TAC number for transfer action is 888787',
            'phones' => [
                '601423423423',
                '60169163324',
            ],
            'groups' => [
                '08bde7ec-8e38-4fb7-a96c-ab72bee42cd3',
            ],
            'preview' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X POST \
    "https://manage.smsniaga.com/api/send" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}" \
    -d '{"body":"RM0.00 WEB IMPIAN: Your TAC number for transfer action is 888787","phones":["601423423423","60169163324"],"groups":["08bde7ec-8e38-4fb7-a96c-ab72bee42cd3"],"preview":1}'
import requests
import json

url = 'https://manage.smsniaga.com/api/send'
payload = {
    "body": "RM0.00 WEB IMPIAN: Your TAC number for transfer action is 888787",
    "phones": [
        "601423423423",
        "60169163324"
    ],
    "groups": [
        "08bde7ec-8e38-4fb7-a96c-ab72bee42cd3"
    ],
    "preview": 1
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200):


{
"data": {
   "total_numbers": 2,
   "groups": [
       0
   ],
   "total_charge": "0.20",
   "numbers": [
       "60169163324"
       "601162509816"
   ],
   "char_counts": 62,
   "message": {
       "uuid": "ea6d7faa-34f0-4789-829e-ecdd12437e4e",
       "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd303",
       "type": 2,
       "debit": 1000,
       "body": "RM0.00 WEB IMPIAN: Your TAC number for transfer action 888787",
       "updated_at": "2020-06-28T02:44:51.000000Z",
       "created_at": "2020-06-28T02:44:51.000000Z"
   },
   "credit_balance": "1.38"
},
"message": "Success",
"status_code": 200
}

Example response (401):

{
    "message": "Missing required parameter.",
    "status_code": 401
}

Request

POST api/send

Body Parameters

body  text
Your message body. RM0.00 and brand name (sender ID) will be automatically prepend in front of message.

phones  array
List of phone numbers in E.164 format, with valid country code 60 (Malaysia) to be use in this sending process.

groups  array optional
optional List of groups UUID get from subscriber groups endpoint.

preview  integer optional
optional Set preview to 1 if you want to preview cost and message.

GET /api/message

Get delivery report for current sending message by UUID.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://manage.smsniaga.com/api/message',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
        'json' => [
            'uuid' => '6dc88ec1-f442-495f-944b-e16b0e1871z4',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET \
    -G "https://manage.smsniaga.com/api/message" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}" \
    -d '{"uuid":"6dc88ec1-f442-495f-944b-e16b0e1871z4"}'
import requests
import json

url = 'https://manage.smsniaga.com/api/message'
payload = {
    "uuid": "6dc88ec1-f442-495f-944b-e16b0e1871z4"
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('GET', url, headers=headers, json=payload)
response.json()

Example response (200):

{
    "message": {
        "uuid": "6dc88ec1-f442-495f-944b-e16b0e1871z4",
        "body": "RM0.00 WEB IMPIAN: Your TAC is 234234",
        "debit": 800,
        "created_at": "2020-06-13T07:00:04.000000Z"
    },
    "count": {
        "total": 1,
        "delivered": 1
    },
    "stats": [
        {
            "phone": "601159250252",
            "delivery_report": 1,
            "delivery_report_code": "000",
            "delivery_report_received": "2020-06-14 14:59:40"
        }
    ]
}

Request

GET api/message

Body Parameters

uuid  string
UUID of message acquired from /send response.

Subscriber

For subscriber related endpoint.

GET /api/subscribers

List of all subscribers.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://manage.smsniaga.com/api/subscribers',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET \
    -G "https://manage.smsniaga.com/api/subscribers" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/subscribers'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):


{
"data": [
    {
        "uuid": "bc88a39a-2ae0-41fa-b4b8-dd830e8e43f4",
        "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd333",
        "name": "Hanny Ramzy",
        "email": "ramzy@webimpian.com",
        "phone": "60169163324",
        "created_at": "2020-06-09T17:38:29.000000Z",
        "updated_at": "2020-06-09T17:38:29.000000Z",
        "group": [
            {
                "uuid": "00aafe8d-2f39-4488-93b1-efcf9c3e0eb9",
                "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd333",
                "name": "Debug Purpose",
                "created_at": "2020-06-09T17:38:29.000000Z",
                "updated_at": "2020-06-09T17:38:29.000000Z"
            }
        ]
    },
    {
        "uuid": "35768888-fff4-431b-a677-44831a3aa887",
        "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2dd303",
        "name": "zamri ismail",
        "email": "zamri@webimpian.com",
        "phone": "60139731056",
        "created_at": "2020-06-09T17:41:22.000000Z",
        "updated_at": "2020-06-09T17:41:22.000000Z",
        "group": [
            {
                "uuid": "00aafe8d-2f39-4488-93b1-efcf9c3e0eb9",
                "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd333",
                "name": "Debug Purpose",
                "created_at": "2020-06-09T17:38:29.000000Z",
                "updated_at": "2020-06-09T17:38:29.000000Z"
            }
        ]
    },
],
"message": "Success",
"status_code": 200
}

Request

GET api/subscribers

api/subscribers

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://manage.smsniaga.com/api/subscribers',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X POST \
    "https://manage.smsniaga.com/api/subscribers" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/subscribers'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('POST', url, headers=headers)
response.json()

Example response (200):

{
    "message": "Unauthenticated",
    "status_code": 403
}

Request

POST api/subscribers

GET /api/subscribers/{subscriber}

Get subscriber resource by specifiying its resource UUID.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://manage.smsniaga.com/api/subscribers/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET \
    -G "https://manage.smsniaga.com/api/subscribers/1" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/subscribers/1'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):


{
"data": [
  "uuid": "bc88a39a-2ae0-41fa-b4b8-dd830e8e43f4",
  "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd333",
  "name": "Hanny Ramzy",
  "email": "ramzy@webimpian.com",
  "phone": "60169163324",
  "created_at": "2020-06-09T17:38:29.000000Z",
  "updated_at": "2020-06-09T17:38:29.000000Z"
  "group": [
      {
        "uuid": "00aafe8d-2f39-4488-93b1-efcf9c3e99b9",
        "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd333",
        "name": "Debug Purpose",
        "created_at": "2020-06-09T17:38:29.000000Z",
        "updated_at": "2020-06-09T17:38:29.000000Z"
      }
  ],
],
"message": "Success",
"status_code": 200
}

Request

GET api/subscribers/{subscriber}

URL Parameters

uuid 
Subscriber resources UUID.

api/subscribers/{subscriber}

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->put(
    'https://manage.smsniaga.com/api/subscribers/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X PUT \
    "https://manage.smsniaga.com/api/subscribers/1" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/subscribers/1'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('PUT', url, headers=headers)
response.json()

Request

PUT api/subscribers/{subscriber}

PATCH api/subscribers/{subscriber}

api/subscribers/{subscriber}

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->delete(
    'https://manage.smsniaga.com/api/subscribers/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X DELETE \
    "https://manage.smsniaga.com/api/subscribers/1" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/subscribers/1'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Request

DELETE api/subscribers/{subscriber}

GET /api/groups

Get listing subscriber groups available for your account.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://manage.smsniaga.com/api/groups',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET \
    -G "https://manage.smsniaga.com/api/groups" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/groups'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):

{
    "data": [
        {
            "uuid": "a2024b4b-be08-4445-9a15-e270a279f752",
            "user_uuid": "3bb1264a-367b-449f-a53d-5ddbcf2cd363",
            "name": "Hot Customer",
            "created_at": "2020-05-28 19:27:09",
            "updated_at": "2020-05-28 19:27:09"
        },
        {
            "uuid": "00aafe8d-2f39-4488-93b1-efcf9c3e0eb9",
            "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd303",
            "name": "Debug Purpose",
            "created_at": "2020-06-09T17:38:29.000000Z",
            "updated_at": "2020-06-09T17:38:29.000000Z"
        },
        {
            "uuid": "85ed09c9-eb20-491f-be3b-58d26c7b3194",
            "user_uuid": "3ab1264c-367a-449e-a53b-5ddacf2cd303",
            "name": "WISB Team HR",
            "created_at": "2020-06-19T12:35:51.000000Z",
            "updated_at": "2020-06-19T12:35:51.000000Z"
        }
    ],
    "message": "Success",
    "status_code": 200
}

Request

GET api/groups

GET /api/groups/{group}

Get subscriber resource by specifiying its resource UUID.

Example request:


$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://manage.smsniaga.com/api/groups/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer {token}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET \
    -G "https://manage.smsniaga.com/api/groups/1" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer {token}"
import requests
import json

url = 'https://manage.smsniaga.com/api/groups/1'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {token}'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):

{
    "data": [
        {
            "uuid": "a2024b4b-be08-4445-9a15-e270a279f752",
            "user_uuid": "3bb1264a-367b-449f-a53d-5ddbcf2cd363",
            "name": "Hot Customer",
            "created_at": "2020-05-28 19:27:09",
            "updated_at": "2020-05-28 19:27:09"
        }
    ],
    "message": "Success",
    "status_code": 200
}

Request

GET api/groups/{group}

URL Parameters

uuid 
Subscriber resources UUID eg: 3bb1264a-367b-449f-a53d-5ddbcf2cd363

Delivery Report Code

Code Description
000 OK. No error encountered.
001 Absent subscriber.
002 Handset memory capacity exceeded. Handset has run out of free memory to store new message.
003 Equipment protocol error.
004 Equipment not equipped with short-message capability
005 Unknown subscriber. The IMSI is unknown in the HLR.
006 Illegal subscriber. The mobile station failed authentication.
007 Teleservice not provisioned. Mobile subscription identified by the MSISDN number does include the short message service.
008 Illegal equipment. IMEI check failed, i.e. the IMEI is either blacklisted or not whitelisted.
009 Call barred. Operator barred the MSISDN number.
010 Facility not supported. VLR in the PLMN does not support MT short message service.
011 Subscriber busy for MT short message.
012 System failure. Task cannot be completed because of a problem in another entity.
013 Data missing. Necessary parameter is not present in the primitive.
014 Unexpected data value. Necessary data is badly formatted in the primitive.
015 Unidentified subscriber.
016 Absent subscriber. No paging response.
017 Absent subscriber. IMSI detached.
018 Absent subscriber. Roaming restriction.
047 Application context not supported.
050 Temporary error received from peer SMSC.
051 SMS malformed. SMS is not formed correctly. This error is specific to IP-based protocols like SMPP
052 SMS expired.
053 Please contact administrator.
054 Invalid destination. Receiver is not a valid number.
055 Unable to find outbound route for this SMS.
056 SMS buffered.
057 Timeout waiting for response from peer.
058 Throttling error. The user has exceeded allowed message limit.
061 Subscriber blacklisted.
062 Subscriber not whitelisted.
069 Invalid sender ID.
071 Subscriber opted out from receiving SMS.
074 SMS rejected. Error received from peer SMSC.
075 SMS rejected. Inappropriate SMS content.
076 Sender ID blacklisted.
077 Sender ID not whilelisted.
255 Unknown error.