You are on page 1of 13

HTTP API INTERFACE

Document Specification v3.0.1

Update 15 October 2020

TCASTSMS® - PT AGARA CIPTA MANDIRI 1|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
TCASTSMS HTTP API INTERFACE SPECIFICATION (HTTP) GET METHODE

SHORT GUIDE SMS HTTP API

1. Get Balance | Page 3

URL: https://<server>/getbalance?account=***&password=***

JSON RESPON: {“status”:0, “balance”:”499740.000000″, “gift”:”0.000000″}

2. Send SMS | Page 3

URL:
https://<server>/sendsms?account=***&password=***&sender=***&numbers=***&content=**
*

JSON RESPON: {“status”:0, “array”:[[6281210100055,1620443]], “success”:1, “fail”:0}

3. Get Report SMS | Page 5

URL: https://<server>/getreport?account=***&password=***&ids=1234567

JSON RESPON: {“status”:0, “array”:[[1234567,6281210100055,20180619101517,0]],


“success”:1, “fail”:0, “unsent”:0, “sending”:0, “nofound”:0}

4. Get SMS (AddOn) | Page 7

URL: https://<server>/getsms?account=***&password=***
JSON RESPON: {"status":0,"cnt":2,"array":[[1,”
628xxx”,”123456”,20171001123015,"********************************"],[2,”
628xxx”,”123456”,20171001123015,"********************************"]]}

5. Actively Push and Send reports to the customer’s URL | Page 8

Json message format parameter

• type: String type of the message, default:“report”


• cnt: Number of reports included in this push (no more than 50 per request
• array: array of send reports Array in turn contains; id (The id returned when sending,int); send number(string); send
time(long int); send results(int,0 success,Non-zero fails); reason(string)

Push sample:

{"type":"report","cnt":2,"array":[[1,"6281210100055",20180801123015,0,"success"],[2
,"6281908080709",20180801223015, 1, "no balance"]]}

6. Sample Script PHP | Page 9


7. Sample Script JAVA | Page 10
8. Sample Script JAVA SCRIPT | Page 11
9. Sample Script .NET | Page 12

TCASTSMS® - PT AGARA CIPTA MANDIRI 2|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
DETAILS DOCUMENTATION

Note: the encoding format of this interface: utf8.

1. Get Balance
HTTP get is supported to obtain the balance of the corresponding account in the system.
Data of query(The body segment of the HTTP message)is a JSON array composed by one or more task. Parameter Content-Type in
HTTP head should set to “application/json;charset=utf-8”.

Method of calling:
https://<server>/getbalance?account=***&password=***

Input parameter:
parameter description required data type
version Protocol version number N(default 1.0) String
account account Y String
password password Y String

Output parameter:
parameter description data type
status query status INT
0:query success
-1:authentication error
-2:IP limited access
balance The balance of the actual account String
gift Complimentary account balance String

Reply sample:
{“status”:0, "balance":"99.990000", "gift":"50.00000"}

2. Send SMS
Support HTTP get or post for sending SMS messages, get sends up to 100 Numbers at a time, and post can submit up to
10,000 Numbers at once.
Submitted results data (The body segment of the HTTP message)is a JSON array composed by one or more task. Parameter
Content-Type in HTTP head should set to “application/json;charset=utf-8”.

Method of calling:
https://<server>/sendsms?account=***&password=***&numbers=628xxx,628xxx&sender=**
*&content=***

TCASTSMS® - PT AGARA CIPTA MANDIRI 3|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
Input parameter:
parameter description required data type
version protocol version number N(default 1.0) String
account account Y String
password password Y String
numbers Sms receiving number, separated by Y
English comma between multiple
Numbers (get up to 100,post up to
10000)
sender Sender id (makesure your sender Y String
working first or have approved by The length
operator, if not yet you can submit should not
document to each operator) exceed 11
content Send content (need to do urlEncode) Y String
The length
should not
exceed 1024
sendtime Timed delivery time (empty is N String(14)
immediately sent)
For example :20171001123015, which
means October 1, 2017, 12:30
minutes and 15 seconds.

Output parameter:
parameter description data type
status Send submission status INT
0:Query success
-1:Authentication error
-2:IP limited access
-3:SMS contain sensitive characters
-4:SMS contain is empty
-5:SMS contain is too long
-6:Not a template SMS
-7:Over number
-8:Number is empty
-9:Abnormal number
-10:The channel balance is insufficient to satisfy this
transmission

TCASTSMS® - PT AGARA CIPTA MANDIRI 4|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
-11:The timing is wrong
-12:Because of the platform, batch commit error, please
contact the administrator
-13: User locked
success The number of successful submissions INT
fail The number of failure submissions INT
array The array of successful SMS submissions
The array contains the "number and number of the
sending result query ID", which is numeric characters.

Note: after the submission of the SMS, the system will generate an Id for the successful number. After that, the customer can query the
sending result of the message according to this Id.

Reply sample:
{"status":0, "success":2, "fail":0, "array":[[628xxx,1], [628xxx,2]]}

3. Get Report
HTTP get is supported to query the SMS sending status, and get sends up to 200 Numbers at once.
Get report data (The body segment of the HTTP message)is a JSON array composed by one or more task. Parameter Content-
Type in HTTP head should set to “application/json;charset=utf-8”.

Method of calling:
https://<server>/getreport?account=***&password=***&ids=1234567,2233445

Input parameter:

parameter description required data type


version Protocol version number N(default 1.0) String
account account Y String
password password Y String
ids Specify the SMS id of the query sending Y String
result (the id is returned by the system at the
time of submission), and multiple Numbers
are separated by English commas (up to 200)

Output parameter:
parameter description data type
status Send submission status INT
0:Query success

TCASTSMS® - PT AGARA CIPTA MANDIRI 5|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
-1:Authentication error
-2:IP limited access
-3:SMS contain sensitive characters
-4:SMS contain is empty
-5:SMS contain is too long
-6:Not a template SMS
-7:Over number
-8:Number is empty
-9:Abnormal number
-10:The channel balance is insufficient to satisfy this
transmission
-11:The timing is wrong
-12:Because of the platform, batch commit error, please
contact the administrator
-13: User locked
-14: Query id abnormal
success the number of send successful INT
fail the number of send failure INT
unsent the number of unsend
sending the number of sending
nofound the number of id not found
array An array of SMS sending results.
The array contains the "status query ID, number, sending
time, status" , all of which are numeric characters.
Status: 0 sent successfully, 1: unsent, 2: sending, non 012
sending failure.

Note: after the submission of the text message, the system will generate an Id for the successful number. After that, the customer can
query the sending result of the message according to this Id.
Reply sample:
{"status":0, "success":1, "fail":1, "unsent":0, "sending":0, "nofound":0,
"array":[[1, 628xxx,20171001123015,0], [2, 628xxx,20171001123015,3]]}

Note: above-mentioned array [1,10010,20171001123015,0],each field corresponds to the status query ID, number, sending time
and status of the number.

TCASTSMS® - PT AGARA CIPTA MANDIRI 6|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
4. Get SMS
Support HTTP get to query the system to receive SMS, get sends up to 50 SMS messages.
Get report data (The body segment of the HTTP message)is a JSON array composed by one or more task. Parameter Content-Type in
HTTP head should set to “application/json;charset=utf-8”。
Method of calling:
https://<server>/getsms?account=***&password=***

Input parameter:
parameter description required data type
version Protocol version number N(default 1.0) String
account account Y String
password password Y String
start_time Timestamp of start the query N INT

Output parameter:
parameter description data type
status Query request status INT
0:Query success
-1:Authentication error
-2:IP limited access
-3:SMS contain sensitive characters
-4:SMS contain is empty
-5:SMS contain is too long
-6:Not a template SMS
-7:Over number
-8:Number is empty
-9:Abnormal number
-10:The channel balance is insufficient to satisfy this
transmission
-11:The timing is wrong
-12:Because of the platform, batch commit error, please
contact the administrator
-13: User locked
cnt receive SMS number of Query (a get request is not more INT
than 50)
array An array of successful SMS
The array contains "id(the unique id in the system),
sending number, sending time, message content",

TCASTSMS® - PT AGARA CIPTA MANDIRI 7|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
Note: the message content needs to be base64 decoded
to get the correct SMS content of utf8 encoding;If you
receive two SMS with the same id, it can be considered as
a repeated receiving SMS. Once the customer has
checked the received SMS, the second query will not
return.

Reply sample:
{"status":0,"cnt":2,"array":[[1,”
628xxx”,”123456”,20171001123015,"********************************"],[2,”
628xxx”,”123456”,20171001123015,"********************************"]]}

5. Actively Push and Send reports to the customer's URL

The url of the push report of the consumer can be configured on the system. After the system sends the SMS, the result of the SMS will
be pushed to the url specified by the customer in the way of put. The content of the report will be placed in the body of the request in the
format of json.Push up to 50 send reports at a time.

Json message format

parameter description data type


type String type of the message, default:“report” STRING
cnt Number of reports included in this push (no more than 50 INT
per request)
array array of send reports array
Array in turn contains
1、 id(The id returned when sending,int)
2、 send number(string)
3、 send time(long int)
4、 send results(int,0 success,Non-zero fails)
5、 reason(string)

Push sample:
{"type":"report","cnt":2,"array":[[1,"6281210100055",20180801123015,0,"success"],[2
,"6281908080709",20180801223015, 1, "no balance"]]}

TCASTSMS® - PT AGARA CIPTA MANDIRI 8|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
Sample Script

PHP

<?php

function Send_SMS( $to, $text ) {


#example $to=”628xxxx,628xxxx”;

$to = str_replace(' ', '',$to);


$from = "xxxx"; //Sender ID or SMS Masking Name, if leave blank, it will use default from
telco
$username = "xxxx"; //your username
$password = "xxxx"; //your password
$getUrl = "https://<server>/sendsms?";
$ch = curl_init();
$apiUrl =
$getUrl.'account='.$username.'&password='.$password.'&numbers='.$to.'&content='.rawurlencode
($text);

curl_setopt( $ch, CURLOPT_URL, $apiUrl);


curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, true);
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept:application/json'
)
);

$response = curl_exec( $ch );


$httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
$responseBody = json_decode( $response, true );

if ($response) {
print_r($response);
}
curl_close($ch);
}

$to = "xxxx";//masukkan nomor tujuan


$message = "xxxx";//masukkan isi pesan
Send_SMS( $to, $message );

?>

TCASTSMS® - PT AGARA CIPTA MANDIRI 9|P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
JAVA

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class SmsRestApiClient {


public static void main(String[] args) {
String tujuan = "6285710100055,6281908080709";
String pesan = "Test sms java client";
SmsRestApiClient smsClientRestApi = new SmsRestApiClient();
smsClientRestApi.sendSms(tujuan, pesan);
}

private void sendSms(String to, String content) {


String account = "xxxxx";
String password = "xxxxx";
try {
URL url = new URL("http://<server>/sendsms?"
+ "account=" + account
+ "&password=" + password
+ "&numbers=" + to.replaceAll(" ","")
+ "&content=" + URLEncoder.encode(content, "UTF-
8").replaceAll("\\+", "%20"));
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP Error code : "
+ conn.getResponseCode());
}
InputStreamReader in = new InputStreamReader(conn.getInputStream());
BufferedReader br = new BufferedReader(in);
String output;
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (Exception e) {
System.out.println("Exception in SmsRestApiClient:- " + e);
}
}
}

TCASTSMS® - PT AGARA CIPTA MANDIRI 10 | P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
JAVA SCRIPT

<!doctype html>
<html lang=”en”>
<head>
<metacharset=”utf-8″>
<title>TCASTSMS</title>
<scriptsrc=”https://code.jquery.com/jquery-1.10.2.js”></script>
</head>
<body>
<div id=”response”></div>
<script>
(function() {
var username =”xxxxx”;
var password =”xxxxx”;
var destination =”628xxxxx”;
var content =”Test Script TCASTSMS JavaScript klik www.tcastsms.co.id”;
var baseUri =”http://<server>/sendsms?”;
var tcastUri = baseUri +
“account=”+ username
+”&password=”+ password
+”&numbers=”+ destination
+”&content=”+encodeURIComponent(content);
$.getJSON( tcastUri)
.done(function( data ) {
document.getElementById(“response”).value= data;
});
})();
</script>
</body>
</html>

TCASTSMS® - PT AGARA CIPTA MANDIRI 11 | P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
.NET

//Rextester.Program.Main is the entry point for your code. Don’t change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace Rextester
{
publicclassDataObject
{
publicstringName { get; set; }
}
publicclassProgram
{
privateconststringURL=”http://<server>/sendsms”;
//private static string urlParameters =
System.Web.HttpUtility.UrlEncode(“account=xxxxx&password=xxxxx&numbers=628xxxxx&content=Test
-Content-SMS”);
publicstaticvoidMain(string[] args)
{
varaccount=”xxxxx”;
varpassword=”xxxxx”;
vardest=”628xxxxx”;
varcontentMsg=System.Web.HttpUtility.UrlPathEncode(“Test Script TCASTSMS .NET klik
www.tcastsms.co.id”);
varfinalUrlParam=”?account=”+account
+”&password=”+password
+”&numbers=”+dest
+”&content=”+contentMsg;
HttpClientclient=newHttpClient();
client.BaseAddress=newUri(URL);
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(
newMediaTypeWithQualityHeaderValue(“application/json”));
// Console.WriteLine(“urlParameters {0}”, finalUrlParam);
// List data response.
HttpResponseMessageresponse=client.GetAsync(finalUrlParam).Result; // Blocking call! Program
will wait here until a response is received or a timeout occurs.
if (response.IsSuccessStatusCode)
{
stringres=””;
TCASTSMS® - PT AGARA CIPTA MANDIRI 12 | P a g e
ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id
using (HttpContentcontent=response.Content)
{
// … Read the string.
Task<string> result=content.ReadAsStringAsync();
res=result.Result;
Console.WriteLine(“{0}”, res);
}
}
else
{
Console.WriteLine(“{0} ({1})”, (int)response.StatusCode, response.ReasonPhrase);
}
//Make any other calls using HttpClient here.
//Dispose once all HttpClient calls are complete. This is not necessary if the containing
object will be disposed of; for example in this case the HttpClient instance will be
disposed automatically when the application terminates so the following call is superfluous.
client.Dispose();
}
}
}

TCASTSMS® - PT AGARA CIPTA MANDIRI 13 | P a g e


ADDRESS: JEPE 9 Building - Jalan Raya Ragunan No.9 Jati Padang, Pasar Minggu Jakarta Selatan 12540 – Indonesia
PHONE: +62. 21 7815328; +62. 21 7823311 EMAIL: marketing@tcastsms.co.id WEB: www.tcastsms.co.id

You might also like