NAV Navigation
CURL Go NodeJS PHP Python Ruby

NusaSMS API v1.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Please be noted that there are two API host, development (test) and production server.

Production

Host: https://api.nusasms.com

You can use this host to make real transaction.

Grab your APIKey on app.nusasms.com, on Account > User management menu.

API Usage Notes

Development (Test)

Development (testing), which userโ€™s client credit top up is for testing only. Any result of this API (this host) is not real. Credit top up is not required on this server host.

On this server, an account (and only one) is being provided to user the API. The APIKey for this test server is DEV_TESTING_API_KEY. Please use the APIkey kindly.

Response

Success

HTTP Response Code, either 200, 201, 202 or 204 and error=false on the json response is success request.

Failed / Error

All neither 200, 201 nor 204 HTTP response code is failed response.

HTTP Status Code

Response Content Type

Authentication

Account

Get user data using API Key

GET /nusasms_api/1.0/auth/api_key

BASE_URL=https://api.nusasms.com
# BASE_URL=https://dev.nusasms.com # For testing

curl ${BASE_URL}/nusasms_api/1.0/auth/api_key \
-H "APIKey: {YOUR_APIKEY}" \
-H 'Content-Type: application/json' \
# --insecure # Ignore SSL Verification
import requests

BASE_URL = "https://api.nusasms.com/nusasms_api/1.0"
# For testing
# BASE_URL = "https://dev.nusasms.com/nusasms_api/1.0"
HEADERS = {
"Accept": "application/json",
"APIKey": "{YOUR_API_KEY}"
}

r = requests.get(
f'{BASE_URL}/auth/api_key',
headers=HEADERS,
# verify=False # Skip SSL Verification
)

print(r.json())
package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"APIKey": []string{" YOUR_API_KEY "},
}
url := "https://api.nusasms.com/nusasms_api/1.0/auth/api_key"
// For testing
// url := "https://dev.nusasms.com/nusasms_api/1.0/auth/api_key"

req, _ := http.NewRequest("GET", url, nil)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)

if err != nil {
panic(err)
}

body, _ := ioutil.ReadAll(resp.Body)

fmt.Println(string(body))
// ...
}
<?php
$BASE_URL = "https://api.nusasms.com/nusasms_api/1.0";
// For testing
// $BASE_URL = "https://dev.nusasms.com/nusasms_api/1.0";

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => array(
'APIKey: {YOUR_API_KEY}',
'Content-Type: application/json'
),
CURLOPT_URL => $BASE_URL . "/auth/api_key",

// CURLOPT_SSL_VERIFYPEER => 0, // Skip SSL Verification
));

$resp = curl_exec($curl);
echo $resp;
curl_close($curl);
const axios = require('axios');

const headers = {
'Accept':'application/json',
'APIKey':'YOUR_API_KEY'
};
const url = 'https://api.nusasms.com/nusasms_api/1.0/auth/api_key'
// Test host
//const url = 'https://dev.nusasms.com/nusasms_api/1.0/auth/api_key'

axios.get(url, {headers: headers})
.then(function(response) {
console.log(response.data)
})
.catch(error => {
if (error.response) {
console.error(error.response.data)
} else if (error.request) {
console.error(error.request)
} else {
console.error(error.message);
}
});
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json',
'APIKey' => 'YOUR_API_KEY'
}
url = 'https://api.nusasms.com/nusasms_api/1.0/auth/api_key'
# Dev host
# url = 'https://dev.nusasms.com/nusasms_api/1.0/auth/api_key'

result = RestClient.get(url, headers=headers)

puts JSON.parse(result)

Example responses

200 Response

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"userid": "string",
"idPerson": 0,
"idClient": 0
}
}

Responses

Status Meaning Description Schema
200 OK Successful Response PersonResponse

Get Balance Data

GET /nusasms_api/1.0/balance

BASE_URL=https://api.nusasms.com/nusasms_api/1.0
# For testing
# BASE_URL=https://dev.nusasms.com/nusasms_api/1.0

curl -X GET "${BASE_URL}/balance" \
-H "accept: application/json" \
-H "APIKey: {YOUR_API_KEY}"
# --insecure # Ignore SSL Verification
<?php
$BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0';
// For test
// $BASE_URL = 'https://dev.nusasms.com/nusasms_api/1.0';

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $BASE_URL . '/balance',
CURLOPT_HTTPHEADER => array(
"APIKey: {YOUR_API_KEY}",
'Accept: application/json',
'Content-Type: application/json'
),
CURLOPT_RETURNTRANSFER => 1,
// CURLOPT_SSL_VERIFYPEER => 0, // Skip SSL Verification
));

$resp = curl_exec($curl);
echo $resp;
curl_close($curl);
import requests

BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0'
# For testing
# BASE_URL = 'https://dev.nusasms.com/nusasms_api/1.0'
HEADERS = {
"Accept": "application/json",
"APIKey": "YOUR_API_KEY"
}

r = requests.get(
f'{BASE_URL}/balance',
headers=HEADERS,
# Skip SSL Verification
# verify = False
)

print(r.json())
package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"APIKey": []string{" YOUR_API_KEY "},
}
url := "https://api.nusasms.com/nusasms_api/1.0/balance"
// For testing
// url := "https://dev.nusasms.com/nusasms_api/1.0/balance"

req, _ := http.NewRequest("GET", url, nil)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)

if err != nil {
panic(err)
}

body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
// ...
}
const axios = require('axios');

const headers = {
'Accept':'application/json',
'APIKey':'YOUR_API_KEY'
};
const url = 'https://api.nusasms.com/nusasms_api/1.0/balance'
// Test host
//const url = 'https://dev.nusasms.com/nusasms_api/1.0/balance'

axios.get(url, {headers})
.then(function(response) {
console.log(response.data)
})
.catch(error => {
if (error.response) {
console.error(error.response.data)
} else if (error.request) {
console.error(error.request)
} else {
console.error(error.message);
}
});
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json',
'APIKey' => 'YOUR_API_KEY'
}
url = 'https://api.nusasms.com/nusasms_api/1.0/balance'
# Dev host
# url = 'https://dev.nusasms.com/nusasms_api/1.0/balance'

result = RestClient.get(url, headers=headers)

puts JSON.parse(result)

Example responses

200 Response

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"idClient": 0,
"wa_balance": 0,
"wa_expired_date": "2019-08-24",
"hlr_balance": 0,
"hlr_expired_date": "2019-08-24",
"sim_balance": 0,
"sim_expired_date": "2019-08-24",
"sms_balance": 0,
"sms_expired_date": "2019-08-24",
"pulsa_balance": 0
}
}

Responses

Status Meaning Description Schema
200 OK Successful Response CreditResponse

WhatsApp

Introduction

Information

Tutorial Video: Send Message using PHP (Bahasa Indonesia)

Whatsapp Message Status

Code Name Description
Q QUEUE Message is on Queue to be proceed
S SENT Message is on process to be sent to the destination
D DELIVERED Message has been delivered
R READ Message has been read on destination side
A ABORT Message has been aborted and not going to be sent anymore
F FAILED Message is not sent. Issue may vary

Emoticons

Source: Full Emoji List

Use the emoji code as API message parameter examples

Emoticons Name Unicode As Message Parameter
๐Ÿ˜€ Grinning face U+1F600 โ€œmessageโ€: โ€œ\\U0001F600โ€
๐Ÿ‡ฎ๐Ÿ‡ฉ flag: Indonesia U+1F1EE U+1F1E9 โ€œmessageโ€: โ€œ\\U0001F1EE\\U0001F1E9โ€

Send Media

POST /nusasms_api/1.0/whatsapp/media

BASE_URL=https://api.nusasms.com/nusasms_api/1.0
# For testing
# BASE_URL=https://dev.nusasms.com/nusasms_api/1.0

curl -X POST "${BASE_URL}/whatsapp/media" \
-H 'Content-type: application/json; charset=utf-8' \
-H "Accept: application/json" \
-H "APIKey: {YOUR_API_KEY}" \
-d "{
\"sender\": \"{YOUR_SENDER}\",
\"destination\": \"628xxxxxxxxxx\",
\"caption\": \"Caption text\",
\"media_url\": \"https://example.com/image_name.png\"
}"

# --insecure # Ignore SSL Verification
# Parameter `sender` is optional
import base64

import requests

BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0'
# For testing
# BASE_URL = 'https://dev.nusasms.com/nusasms_api/1.0'

with open('file_name.png', 'rb') as file_descriptor:
file_data = file_descriptor.read()

base64_file = base64.b64encode(file_data).decode('utf8')

headers = {
"Accept": "application/json",
"APIKey": "{YOUR_API_KEY}"
}
payloads = {
'destination': '628xxxxxxxxxx',
# Sender is optional
'sender': YOUR_SENDER,
'media_base64': base64_file,
'file_name': 'your_image_file.png',
'caption': 'Caption text'
}

# Send file with base64 encoded file
r = requests.post(
f'{BASE_URL}/whatsapp/media',
headers=headers,
json=payloads,
# verify=False # Skip SSL Verification
)

print(r.json())
<?php
$BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0/whatsapp';
$BASE_TEST_URL = 'https://dev.nusasms.com/nusasms_api/1.0/whatsapp';

$curl = curl_init();

$payload = json_encode(array(
'caption' => 'Caption text',
// Sender is optional
'sender' => 'YOUR_SENDER',
'destination' => '628xxxxxxxxxx',
'media_url' => 'https://example.com/image_name.png'
));

curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $BASE_URL . '/media',
// For testing
// CURLOPT_URL => $BASE_TEST_URL . '/media',
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => array(
"APIKey: {YOUR_API_KEY}",
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => $payload,
// CURLOPT_SSL_VERIFYPEER => 0, // Skip SSL Verification
));

$resp = curl_exec($curl);

if (!$resp) else
curl_close($curl);
package main

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)

func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"APIKey": []string{"YOUR_API_KEY"},
}
payload, _ := json.Marshal(map[string]string{
// Optional
// "sender": " YOUR_SENDER ",
"destination": "628xxxxxxxxxx",
"caption": "Caption text",
"media_url": "https://example.com/image_name.png",
})
url := "https://api.nusasms.com/nusasms_api/1.0/whatsapp/media"
// For testing
// url := "https://dev.nusasms.com/nusasms_api/1.0/whatsapp/media"

req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}

body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
// ...
}
const axios = require('axios');

const headers = {
Accept: 'application/json',
APIKey: 'YOUR_API_KEY'
};
var data = {
destination: '628xxxxxxxxxx',
// Sender is optional
sender: 'YOUR_SENDER',
caption: 'Caption text',
media_url: 'https://example.com/your-image.png'
}
const url = 'https://api.nusasms.com/nusasms_api/1.0/whatsapp/media'
// Test host
//const url = 'https://dev.nusasms.com/nusasms_api/1.0/whatsapp/media'

axios.post(url, data, {headers})
.then(response => {
console.log(response.data)
})
.catch(error => {
if (error.response) {
console.error(error.response.data)
} else if (error.request) {
console.error(error.request)
} else {
console.error(error.message);
}
});
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json',
'APIKey' => 'YOUR_API_KEY',
'Content-Type' => 'application/json',
}
payloads = {
'destination' => '628xxxxxxxxxx',
# Sender is optional
'sender' => 'YOUR_SENDER',
'caption' => 'Caption text',
'media_url' => 'https://example.com/your-image.png'
}
base_url = 'https://api.nusasms.com/nusasms_api/1.0'
# Dev host
# base_url = 'https://dev.nusasms.com/nusasms_api/1.0'

response = RestClient::Request.new({
method: :post,
url: base_url + '/whatsapp/media',
payload: payloads.to_json,
headers: headers
}).execute do |response, request, result|
case response.code
# Success
when 201
[ :success, puts(response.to_str) ]
when 400
[
:error,
puts("Failed status_code=#{response.code} response=#{response.to_str}")
]
when 403
[
:error,
puts("Failed status_code=#{response.code} response=#{response.to_str}")
]
when 422
[
:error,
puts("Failed status_code=#{response.code} response=#{response.to_str}")
]
else
[
:error,
puts("Failed response=#{response.to_str}")
]
end
end

Warning

Note

Body parameter

{
"timeout": 0,
"sender": "string",
"queue": "string",
"is_group": false,
"destination": "string",
"caption": "string",
"media_url": "http://example.com",
"media_base64": "string",
"file_name": "string"
}

Parameters

Name In Type Required Description
body body SendMediaParams true none

Example responses

201 Response

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"sender": "string",
"queue": "string",
"destination": "string",
"caption": "string",
"media_url": "string",
"ref_no": "string"
}
}

Responses

Status Meaning Description Schema
201 Created Successful Response SendMediaResponse
422 Unprocessable Entity Validation Error HTTPValidationError

Send Message

POST /nusasms_api/1.0/whatsapp/message

BASE_URL=https://api.nusasms.com/nusasms_api/1.0
# For testing
# BASE_URL=https://dev.nusasms.com/nusasms_api/1.0

curl -X POST "${BASE_URL}/whatsapp/message" \
-H 'Content-type: application/json; charset=utf-8' \
-H "Accept: application/json" \
-H "APIKey: {YOUR_API_KEY}" \
-d "{
\"destination\": \"628xxxxxxxxxx\",
\"message\": \"Message text\"
}"

# --insecure # Ignore SSL Verification
# Parameter `sender` is optional
<?php
$BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0/whatsapp';
$BASE_TEST_URL = 'https://dev.nusasms.com/nusasms_api/1.0/whatsapp';

$curl = curl_init();
$payload = json_encode(array(
// 'sender' => 'YOUR_SENDER',
'destination' => '628xxxxxxxxxx',
'message' => 'Your message'
));
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $BASE_URL . '/message',
// For testing
// CURLOPT_URL => $BASE_TEST_URL . '/message',
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => array(
"APIKey: {YOUR_API_KEY}",
'Content-Type:application/json'
),
CURLOPT_POSTFIELDS => $payload,
// CURLOPT_SSL_VERIFYPEER => 0, // Skip SSL Verification
));

$resp = curl_exec($curl);

if (!$resp) else
curl_close($curl);
import requests

BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0'
# For testing
# BASE_URL = 'https://dev.nusasms.com/nusasms_api/1.0'

HEADERS = {
"Accept": "application/json",
"APIKey": "YOUR_API_KEY"
}
PAYLOADS = {
'destination': '628xxxxxxxxxx',
# Optional
'sender': 'YOUR_SENDER',
'message': "your message here.\\nGrinning face emoticon: \\\\U0001F600"
}

r = requests.post(
f'{BASE_URL}/whatsapp/message',
headers=HEADERS,
json=PAYLOADS,
# Skip SSL Verification
# verify=False
)

print(r.json())
package main

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)

func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"APIKey": []string{"YOUR_API_KEY"},
}
payload, _ := json.Marshal(map[string]string{
// Sender is optional
// "sender": "YOUR_SENDER",
"destination": "628xxxxxxxxxx",
"message": "Message text",
})
url := "https://api.nusasms.com/nusasms_api/1.0/whatsapp/message"
// For testing
// url := "https://dev.nusasms.com/nusasms_api/1.0/whatsapp/message"

req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}

body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
// ...
}
const axios = require('axios');

const headers = {
Accept: 'application/json',
APIKey: 'YOUR_API_KEY'
};
var data = {
// sender: 'YOUR_SENDER',
destination: '628xxxxxxxxxx',
message: 'Message text',
}
const url = 'https://api.nusasms.com/nusasms_api/1.0/whatsapp/message'
// Test host
//const url = 'https://dev.nusasms.com/nusasms_api/1.0/whatsapp/message'

axios.post(url, data, {headers})
.then(response => {
console.log(response.data)
})
.catch(error => {
if (error.response) {
console.error(error.response.data)
} else if (error.request) {
console.error(error.request)
} else {
console.error(error.message);
}
});
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json',
'APIKey' => 'YOUR_API_KEY',
'Content-Type' => 'application/json',
}
payloads = {
# 'sender' => 'YOUR_SENDER',
'destination' => '628xxxxxxxxxx',
'message' => 'Message text',
}
base_url = 'https://api.nusasms.com/nusasms_api/1.0'
# Dev host
# base_url = 'https://dev.nusasms.com/nusasms_api/1.0'

response = RestClient::Request.new({
method: :post,
url: base_url + '/whatsapp/message',
payload: payloads.to_json,
headers: headers
}).execute do |response, request, result|
case response.code
# Success
when 201
[ :success, puts(response.to_str) ]
when 400
[
:error,
puts("Failed status_code=#{response.code} response=#{response.to_str}")
]
when 403
[
:error,
puts("Failed status_code=#{response.code} response=#{response.to_str}")
]
when 422
[
:error,
puts("Failed status_code=#{response.code} response=#{response.to_str}")
]
else
[
:error,
puts("Failed response=#{response.to_str}")
]
end
end

Note

Body parameter

{
"timeout": 0,
"sender": "string",
"queue": "string",
"is_group": false,
"destination": "string",
"message": "string"
}

Parameters

Name In Type Required Description
body body SendMessageParams true none

Example responses

201 Response

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"sender": "string",
"queue": "string",
"destination": "string",
"message": "string",
"ref_no": "string"
}
}

Responses

Status Meaning Description Schema
201 Created Successful Response SendMessageResponse
422 Unprocessable Entity Validation Error HTTPValidationError

Message Info

GET /nusasms_api/1.0/whatsapp/status/{ref_no}

BASE_URL=https://api.nusasms.com/nusasms_api/1.0
# For testing
# BASE_URL=https://dev.nusasms.com/nusasms_api/1.0

curl -X GET "${BASE_URL}/whatsapp/status/{MESSAGE_REF_NO}" \
-H "accept: application/json" \
-H "APIKey: {YOUR_API_KEY}"
# --insecure # Ignore SSL Verification
<?php
$BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0/whatsapp';
$BASE_TEST_URL = 'https://dev.nusasms.com/nusasms_api/1.0/whatsapp';

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $BASE_URL . '/status/{MESSAGE_REF_NO}',
CURLOPT_HTTPHEADER => array(
"APIKey: {YOUR_API_KEY}",
'Content-Type:application/json'
),
CURLOPT_RETURNTRANSFER => 1,
// CURLOPT_SSL_VERIFYPEER => 0, // Skip SSL Verification
));

$resp = curl_exec($curl);
if (!$resp) else
curl_close($curl);
import requests

BASE_URL = 'https://api.nusasms.com/nusasms_api/1.0'
# For testing
# BASE_URL = 'https://dev.nusasms.com/nusasms_api/1.0'

HEADERS = {
"Accept": "application/json",
"APIKey": "{YOUR_API_KEY}"
}

r = requests.get(
f'{BASE_URL}/whatsapp/status/',
headers=HEADERS,
# Skip SSL Verification
# verify=False
)

print(r.json())
package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func main() {

headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"APIKey": []string{"YOUR_API_KEY"},
}

url := "https://api.nusasms.com/nusasms_api/1.0/whatsapp/status/{MESSAGE_REF_NO}"
// For testing
// url := "https://dev.nusasms.com/nusasms_api/1.0/whatsapp/status/{YOUR_REF_NO}"

req, err := http.NewRequest("GET", url, nil)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}

body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
// ...
}
const axios = require('axios');

const headers = {
'Accept':'application/json',
'APIKey':'YOUR_API_KEY'
};
const url = 'https://api.nusasms.com/nusasms_api/1.0/whatsapp/status'
// Test host
//const url = 'https://dev.nusasms.com/nusasms_api/1.0/whatsapp/status'
var ref_no = 'MESSAGE_REF_NO'

axios.get(url + '/' + ref_no, {headers: headers})
.then(response => {
console.log(response.data)
})
.catch(error => {
if (error.response) {
console.error(error.response.data)
} else if (error.request) {
console.error(error.request)
} else {
console.error(error.message);
}
});
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json',
'APIKey' => 'YOUR_API_KEY'
}
url = 'https://api.nusasms.com/nusasms_api/1.0'
# Dev host
# url = 'https://dev.nusasms.com/nusasms_api/1.0'

result = RestClient.get(
url + '/whatsapp/status/MESSAGE_REF_NO',
headers=headers
)

puts JSON.parse(result)

Whatsapp message status

Status Name Description
U UN-SENT Message is going to be added to queue
Q QUEUE Message is on queue (going to be sent)
S SENT Message is being sent
D DELIVERED Message is delivered to destination
R READ Message has been read
A ABORTED Message is aborted (will not be sent)
F FAILED Fail to save Message (WA Credit deduction will be reverted)

Note: if you set your own sender, please consider to set push callback to get immediate report of your message status to your server. Please contact support to set your push callback.

Test status on Test Server, with ref_no namely listed below:

Parameters

Name In Type Required Description
ref_no path string true none

Example responses

200 Response

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"destination": "string",
"sender": "string",
"is_group": false,
"create_date": "2019-08-24T14:15:22Z",
"sent_date": "2019-08-24T14:15:22Z",
"read_date": "2019-08-24T14:15:22Z",
"delivered_date": "2019-08-24T14:15:22Z",
"ref_no": "string",
"status": "string",
"message": "string",
"caption": "string",
"media_url": "string"
}
}

Responses

Status Meaning Description Schema
200 OK Successful Response GetMessageResponse
422 Unprocessable Entity Validation Error HTTPValidationError

Inbox Push URL

# This script is need to be run on a Server with
# public IP or Domain

import json
from flask import Flask, request

app = Flask(__name__)

@app.route('/your_callback_url', methods=['POST'])
def get_push_callback():
callback_data = {
'id': request.form.get('id'),
'gateway_no': request.form.get('gateway_number'),
'sender': request.form.get('originator'),
'receive_date': request.form.get('receive_date'),
'message': request.form.get('msg'),
}
# You might want to save the result to DB or else here
return json.dumps(callback_data)
/* This script is need to be run on a Server with
* public IP or Domain
*/

$id = $_POST["id"];
$gateway_no = $_POST["gateway_number"];
$sender = $_POST["originator"];
$receive_date = $_POST["receive_date"];
$message = $_POST["msg"];

# you can write your code here, for example if you want to write the data to a file;
$myfile = fopen("inbox.txt", "w") or die("Unable to open file!");

fwrite($myfile, "ID: " . $id . PHP_EOL);
fwrite($myfile, "Gateway No: " . $gateway_no . PHP_EOL);
fwrite($mufile, "Sender: " . $sender . PHP_EOL);
fwrite($myfile, "Receive Date: " . $receive_date . PHP_EOL);
fwrite($myfile, "Message: " . $message . PHP_EOL);
fclose($myfile);

Set your Push URL to let us notify you of your WA message status.

Set Up

SMS

Note

Response Status

Status Value Description
ALL_RECIPIENTS_PROCESSED 0 Request was successful (all recipients)
SEND_ERROR -1 Error in processing the request
NOT_ENOUGH_CREDITS -2 Not enough credits on a specific account
NETWORK_NOTCOVERED -3 Targeted network is not covered on specific account
INVALID_USER_OR_PASS -5 Username or password is invalid
MISSING_DESTINATION_ADDRESS -6 Destination address is missing in the request
BALANCE_EXPIRED -7 Balance has expired
REJECTED -10 OTP messages that do not use an OTP route will be REJECTED
INVALID_DESTINATION_ADDRESS -11 Number is not recognized by NusaSMS platform
MISSING_MESSAGE -12 Message is missing in the request
INVALID_DESTINATION_ADDRESS -13 Number is not recognized by NusaSMS platform
SYNTAX_ERROR -22 Incorrect XML format, caused by syntax error
ERROR_PROCESSING -23 General error, reasons may vary
COMMUNICATION_ERROR -26 General API error, reasons may vary
INVALID_SENDDATETIME -27 Invalid scheduling parametar
INVALID_DELIVERY_REPORT_PUSH_URL -28 Invalid PushURL in the request
INVALID_CLIENT_APPID -30 Invalid APPID in the request
DUPLICATE_MESSAGEID -33 Duplicated MessageID in the request
SENDER_NOT_ALLOWED -34 Sender name is not allowed
IP_ADDRESS_FORBIDDEN -40 Client IP Address Not In White List
SPAM_PATTERN -77 More than 10 same message send to the same recipeints in 1 day
LIMIT REACHED FOR DESTINATION NUMBER -78 Sending messages to the same number has reached the limit in 24 hours
REJECTED ROUTE -88 Operator Rejected The Request
GENERAL_ERROR -99 Error in processing request, reasons may vary

Send Plain

POST /sms/v3/sendsms/plain

Notes

Parameters

Parameter Required Description
user โœ” Your API username
password โœ” You API Password
SMSText โœ” Text message (160 characters)
GSM โœ” GMS recipient number in intenational format (e.g: 62810000XXXX)
unicode โœ˜ True for unicode message
otp โœ˜ Y for OTP message
output โœ˜ json or xml (default)

Parameterized URL Examples

Plain SMS:

https://api.nusasms.com/api/v3/sendsms/plain?user=user&password=password&SMSText=Hello%20NusaSMS!&GSM=628*********

Plain SMS (JSON Response):

https://api.nusasms.com/api/v3/sendsms/plain?user=user&password=password&SMSText=Kode%20OTP%20anda%20xxxxxx&GSM=628********&otp=Y&output=json

OTP SMS:

https://api.nusasms.com/api/v3/sendsms/plain?user=user&password=password&SMSText=Hello%20NusaSMS!&GSM=628********&otp=Y

Success Response Examples

XML

<?xml version="1.0" encoding="UTF-8"?>
<results>
     <result>
          <status>0</status>
          <messageid>175041319203754627</messageid>
          <destination>6285100803380</destination>
     </result>
</results>

JSON

{
    "results": [{
        "status": "0", "messageid": "175041319203754627",
        "destination": "628510080XXXX"
    }]
}

Wrong User / Password Response

XML

<?xml version="1.0" encoding="UTF-8"?>
<results>
     <result>
          <status>-5</status>
          <messageid></messageid>
          <destination>6285100803380</destination>
     </result>
</results>

JSON

{
    "results": [{
        "status": "-5",
        "messageid": "",
        "destination": "6285100803380"
    }]
}

Missing Destination Number Response

XML

<?xml version="1.0" encoding="UTF-8"?> 
  <results> 
     <result> 
       <status>-13</status> 
       <messageid></messageid> 
       <destination>085100803380</destination> 
    </result>
</results>

JSON

{
    "results": [{
        "status": "-13", 
        "messageid": "", 
        "destination": "6285100803380"
    }]
}

Parameters

Name In Type Required Description
user query string true none
password query string true none
SMSText query string true none
unicode query string false none
GSM query string false none
otp query string false none

Example responses

200 Response

null

Responses

Status Meaning Description Schema
200 OK Successful Response Inline
422 Unprocessable Entity Validation Error HTTPValidationError

Response Schema

Send Group

POST /sms/v3/sendsms/group

Notes

Parameters

Parameter Required Description
user โœ” Your API username
password โœ” You API Password
SMSText โœ” Text message (160 characters)
group โœ” Contacts Group name
unicode โœ˜ True for unicode message
otp โœ˜ Y for OTP message
output โœ˜ json or xml (default)

Parameterized URL Example

https://api.nusasms.com/api/v3/sendsms/group?user=user&password=password&SMSText=Hello%20NusaSMS!&group=Example

Result Example

XML

<?xml version="1.0" encoding="UTF-8"?>
<results>
  <result>
    <status>0</status>
    <campaign_name>Group-Api-Campaign-cf27252-5101</campaign_name>
    <group>Example</group>
    </result>
</results>

JSON

{
    "results": [{
        "status": "0", 
        "campaign_name": "Group-Api-Campaign-cf27252-5101",
        "group": "Example"
    }]
}

Failed Response

Group is not available or the group has no contact list

XML

<?xml version="1.0" encoding="UTF-8"?>
<results>
     <result>
          <status>-55</status>
          <campaign_name>Group-Api-Campaign-cf27252-5101</campaign_name>
          <group>Example</group>
     </result>
</results>

JSON

{
    "results": [{
        "status": "-55", 
        "campaign_name": "Group-Api-Campaign-cf27252-5101", 
        "group": "Example"
    }]
}

Parameters

Name In Type Required Description
user query string true none
password query string true none
SMSText query string true none
unicode query string false none
group query string false none
otp query string false none

Example responses

200 Response

null

Responses

Status Meaning Description Schema
200 OK Successful Response Inline
422 Unprocessable Entity Validation Error HTTPValidationError

Response Schema

Command

GET /sms/command

Notes

Command List

Additional parameter

Parameterized URL Examples

Check Credit

https://api.nusasms.com/api/command?user=user&password=password&cmd=CREDITS&type=sms&output=json

Check message status

https://api.nusasms.com/api/command?user=user&password=password&cmd=DR&ref_no=766387461827XXX

API Callback

Another way to get message delivery status is by registering your Server Callback URL on Account Setting menu on app.nusasms.com

Account setting menu

Then set the callback URL

Callback URL Form

Example responses

200 Response

null

Responses

Status Meaning Description Schema
200 OK Successful Response Inline

Response Schema

Push URL

import json
from flask import Flask, request

app = Flask(__name__)

@app.route('/your_callback_url', methods=['POST'])
def get_push_callback():
callback_data = {
'id': request.form.get('id'),
'gateway_no': request.form.get('gateway_number'),
'sender': request.form.get('originator'),
'receive_date': request.form.get('receive_date'),
'message': request.form.get('msg'),
}
# You might want to save the result to DB or else here
return json.dumps(callback_data)
<?php

/* This script is need to be run on a Server with
* public IP or Domain
*/


$id = $_POST["id"];
$gateway_no = $_POST["gateway_number"];
$sender = $_POST["originator"];
$receive_date = $_POST["receive_date"];
$message = $_POST["msg"];

# you can write your code here, for example if you want to
# write the data to a file;
$myfile = fopen("inbox.txt", "w") or die("Unable to open file!");

fwrite($myfile, "ID: " . $id . PHP_EOL);
fwrite($myfile, "Gateway No: " . $gateway_no . PHP_EOL);
fwrite($mufile, "Sender: " . $sender . PHP_EOL);
fwrite($myfile, "Receive Date: " . $receive_date . PHP_EOL);
fwrite($myfile, "Message: " . $message . PHP_EOL);
fclose($myfile);

Set your SMS Push URL to let us notify you (via HTTP) when SMS is coming.

Set Up

Changelog

v1.0

Changed

v0.x

Added

Schemas

Credit

{
"idClient": 0,
"wa_balance": 0,
"wa_expired_date": "2019-08-24",
"hlr_balance": 0,
"hlr_expired_date": "2019-08-24",
"sim_balance": 0,
"sim_expired_date": "2019-08-24",
"sms_balance": 0,
"sms_expired_date": "2019-08-24",
"pulsa_balance": 0
}

Credit

Properties

Name Type Required Restrictions Description
idClient integer true none none
wa_balance number false none none
wa_expired_date string(date) false none none
hlr_balance number false none none
hlr_expired_date string(date) false none none
sim_balance number false none none
sim_expired_date string(date) false none none
sms_balance number false none none
sms_expired_date string(date) false none none
pulsa_balance number false none none

CreditResponse

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"idClient": 0,
"wa_balance": 0,
"wa_expired_date": "2019-08-24",
"hlr_balance": 0,
"hlr_expired_date": "2019-08-24",
"sim_balance": 0,
"sim_expired_date": "2019-08-24",
"sms_balance": 0,
"sms_expired_date": "2019-08-24",
"pulsa_balance": 0
}
}

CreditResponse

Properties

Name Type Required Restrictions Description
error boolean false none none
error_code integer false none none
message string false none none
data Credit true none none

GetMessage

{
"destination": "string",
"sender": "string",
"is_group": false,
"create_date": "2019-08-24T14:15:22Z",
"sent_date": "2019-08-24T14:15:22Z",
"read_date": "2019-08-24T14:15:22Z",
"delivered_date": "2019-08-24T14:15:22Z",
"ref_no": "string",
"status": "string",
"message": "string",
"caption": "string",
"media_url": "string"
}

GetMessage

Properties

Name Type Required Restrictions Description
destination string false none none
sender string false none none
is_group boolean false none none
create_date string(date-time) false none none
sent_date string(date-time) false none none
read_date string(date-time) false none none
delivered_date string(date-time) false none none
ref_no string false none none
status string false none none
message string false none none
caption string false none none
media_url string false none none

GetMessageResponse

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"destination": "string",
"sender": "string",
"is_group": false,
"create_date": "2019-08-24T14:15:22Z",
"sent_date": "2019-08-24T14:15:22Z",
"read_date": "2019-08-24T14:15:22Z",
"delivered_date": "2019-08-24T14:15:22Z",
"ref_no": "string",
"status": "string",
"message": "string",
"caption": "string",
"media_url": "string"
}
}

GetMessageResponse

Properties

Name Type Required Restrictions Description
error boolean false none none
error_code integer false none none
message string false none none
data GetMessage true none none

HTTPValidationError

{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}

HTTPValidationError

Properties

Name Type Required Restrictions Description
detail [ValidationError] false none none

Person

{
"userid": "string",
"idPerson": 0,
"idClient": 0
}

Person

Properties

Name Type Required Restrictions Description
userid string true none none
idPerson integer true none none
idClient integer true none none

PersonResponse

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"userid": "string",
"idPerson": 0,
"idClient": 0
}
}

PersonResponse

Properties

Name Type Required Restrictions Description
error boolean false none none
error_code integer false none none
message string false none none
data Person true none none

SendMedia

{
"sender": "string",
"queue": "string",
"destination": "string",
"caption": "string",
"media_url": "string",
"ref_no": "string"
}

SendMedia

Properties

Name Type Required Restrictions Description
sender string false none none
queue string false none none
destination string true none none
caption string false none none
media_url string false none none
ref_no string true none none

SendMediaParams

{
"timeout": 0,
"sender": "string",
"queue": "string",
"is_group": false,
"destination": "string",
"caption": "string",
"media_url": "http://example.com",
"media_base64": "string",
"file_name": "string"
}

SendMediaParams

Properties

Name Type Required Restrictions Description
timeout integer false none none
sender string false none none
queue string false none none
is_group boolean false none none
destination string true none none
caption string false none none
media_url string(uri) false none none
media_base64 string false none none
file_name string false none none

SendMediaResponse

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"sender": "string",
"queue": "string",
"destination": "string",
"caption": "string",
"media_url": "string",
"ref_no": "string"
}
}

SendMediaResponse

Properties

Name Type Required Restrictions Description
error boolean false none none
error_code integer false none none
message string false none none
data SendMedia true none none

SendMessage

{
"sender": "string",
"queue": "string",
"destination": "string",
"message": "string",
"ref_no": "string"
}

SendMessage

Properties

Name Type Required Restrictions Description
sender string false none none
queue string false none none
destination string true none none
message string false none none
ref_no string true none none

SendMessageParams

{
"timeout": 0,
"sender": "string",
"queue": "string",
"is_group": false,
"destination": "string",
"message": "string"
}

SendMessageParams

Properties

Name Type Required Restrictions Description
timeout integer false none none
sender string false none none
queue string false none none
is_group boolean false none none
destination string true none none
message string true none none

SendMessageResponse

{
"error": false,
"error_code": 0,
"message": "Data message",
"data": {
"sender": "string",
"queue": "string",
"destination": "string",
"message": "string",
"ref_no": "string"
}
}

SendMessageResponse

Properties

Name Type Required Restrictions Description
error boolean false none none
error_code integer false none none
message string false none none
data SendMessage true none none

ValidationError

{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}

ValidationError

Properties

Name Type Required Restrictions Description
loc [string] true none none
msg string true none none
type string true none none