Bulk Messaging API

Last updated: 25th September, 2018

GET - Send Message

Description

Send text messages to either single contact

Request Endpoint

https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=xxxxx&to=xxxxxxxxxx&msg=xxxxxx

Request Type

GET

Request Parameters

Header
Content-Type optional The default (and only) response content type is application/json
Query
username required Your API client username. You can get this from your profile page or client applications (reseller) page.
password required Your API client password. You can get this from your profile page or client applications (reseller) page.
from required The sender name of your message. This must not be more than 11 characters long and must not contain any copyrighted names or names that could deceive recipients.
to required The recipient of your message.
msg required A url encoded content of your message. Every 160 characters in this parameter constitute a full part and is equivalent to 1 SMS Credit. This parameter should be not be more than 800 characters (5 parts).

Response


{
    "status": "true",
    "message": "SMS sending succeeded"
}
                                            

Response Parameters

status A boolean description of the status of the request.
message A text description of the status of the request.

Sample Request


curl -X GET \
'https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=TestSender&to=0XXXXXXXXX&msg=Hello%2C%20I%20am%20testing%20GiantSMS%20bulk%20messaging%20service%20using%20API' \
-H 'Accept: application/json' \
-H 'Cache-Control: no-cache' \
                                                        

$request = new HttpRequest();
$request->setUrl('https://giantsms.com/servicer/api/v1/send');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
    'username' => 'xxxxx',
    'password' => 'xxxxx',
    'from' => 'TestSender',
    'to' => '0XXXXXXXXX',
    'msg' => 'Hello, I am testing GiantSMS bulk messaging service using API'
));

$request->setHeaders(array(
    'Cache-Control' => 'no-cache',
    'Accept' => 'application/json'
));

try {
    $response = $request->send();

    echo $response->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
                                                    

var client = new RestClient("https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=TestSender&to=0XXXXXXXXX&msg=Hello%2C%20I%20am%20testing%20GiantSMS%20bulk%20messaging%20service%20using%20API");
var request = new RestRequest(Method.GET);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "application/json");
IRestResponse response = client.Execute(request);
                                                    

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
    .url("https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=TestSender&to=0XXXXXXXXX&msg=Hello%2C%20I%20am%20testing%20GiantSMS%20bulk%20messaging%20service%20using%20API")
    .get()
    .addHeader("Accept", "application/json")
    .addHeader("Cache-Control", "no-cache")
    .build();

Response response = client.newCall(request).execute();
                                                    

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
    console.log(this.responseText);
    }
});

xhr.open("GET", "https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=TestSender&to=0XXXXXXXXX&msg=Hello%2C%20I%20am%20testing%20GiantSMS%20bulk%20messaging%20service%20using%20API");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Cache-Control", "no-cache");

xhr.send(data);
                                                    

#import 

NSDictionary *headers = @{ @"Accept": @"application/json",
                        @"Cache-Control": @"no-cache",

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=TestSender&to=0XXXXXXXXX&msg=Hello%2C%20I%20am%20testing%20GiantSMS%20bulk%20messaging%20service%20using%20API"]
                                                    cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                        completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                            if (error) {
                                                NSLog(@"%@", error);
                                            } else {
                                                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                NSLog(@"%@", httpResponse);
                                            }
                                        }];
[dataTask resume];
                                                    

import Foundation

let headers = [
    "Accept": "application/json",
    "Cache-Control": "no-cache",
]

let request = NSMutableURLRequest(url: NSURL(string: "https://giantsms.com/servicer/api/v1/send?username=xxxxx&password=xxxxx&from=TestSender&to=0XXXXXXXXX&msg=Hello%2C%20I%20am%20testing%20GiantSMS%20bulk%20messaging%20service%20using%20API")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
    print(error)
    } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
    }
})

dataTask.resume()
                                                    

import http.client

conn = http.client.HTTPConnection("giantsms,com")

headers = {
    'Accept': "application/json",
    'Cache-Control': "no-cache",
    }

conn.request("GET", "api,v1,send", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
                                                    

POST - Send Message

Description

Send text messages to either single contact

Request Endpoint

https://giantsms.com/servicer/api/v1/send

Request Type

POST

Request Parameters

Header
Authorization required Basic $token - Where $token is your API token found on your profile page or client applications (reseller) page.
Content-Type optional The default request and response content type is application/json
Body
from required The sender name of your message. This must not be more than 11 characters long and must not contain any copyrighted names or names intended to deceive recipients.
to required The recipients of your message. Multiple recipients should be separated by a comma (,)
msg required The content of your message. Every 160 characters in this parameter constitute a full message and is equivalent to 1 SMS Credit. This parameter should be not be more than 800 characters (5 messages).

Request Payload


{
    "from": "Sender",
    "to": "0XXXXXXXXX",
    "msg": "Hello, I am testing GiantSMS"
}
                                        

Response


{
    "status": "true",
    "message": "SMS sending succeeded"
}
                                            

Response Parameters

status A boolean description of the status of the request.
message A text description of the status of the request.

Sample Request


    curl -X POST \
    https://giantsms.com/servicer/api/v1/send \
    -H 'Accept: application/json' \
    -H 'Authorization: Basic' \
    -H 'Cache-Control: no-cache' \
    -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
    -F from=TestSender \
    -F to=0xxxxxxxxx \
    -F 'msg=Hello, I am testing GiantSMS bulk messaging API service'

setUrl('https://giantsms.com/servicer/api/v1/send');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
    'Cache-Control' => 'no-cache',
    'Authorization' => 'Basic',
    'Accept' => 'application/json',
    'content-type' => 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
));

$request->setBody('------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="from"

TestSender
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="to"

0xxxxxxxxx
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="msg"

Hello, I am testing GiantSMS bulk messaging API service
------WebKitFormBoundary7MA4YWxkTrZu0gW--');

try {
    $response = $request->send();

    echo $response->getBody();
} catch (HttpException $ex) {
    echo $ex;
}

var client = new RestClient("https://giantsms.com/servicer/api/v1/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "Basic");
request.AddHeader("Accept", "application/json");
request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"from\"\r\n\r\nTestSender\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"to\"\r\n\r\n0xxxxxxxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"msg\"\r\n\r\nHello, I am testing GiantSMS bulk messaging API service\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"from\"\r\n\r\nTestSender\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"to\"\r\n\r\n0xxxxxxxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"msg\"\r\n\r\nHello, I am testing GiantSMS bulk messaging API service\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
    .url("https://giantsms.com/servicer/api/v1/send")
    .post(body)
    .addHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
    .addHeader("Accept", "application/json")
    .addHeader("Authorization", "Basic")
    .addHeader("Cache-Control", "no-cache")
    .build();

Response response = client.newCall(request).execute();

var data = new FormData();
data.append("from", "TestSender");
data.append("to", "0xxxxxxxxx");
data.append("msg", "Hello, I am testing GiantSMS bulk messaging API service");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
    console.log(this.responseText);
    }
});

xhr.open("POST", "https://giantsms.com/servicer/api/v1/send");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", "Basic");
xhr.setRequestHeader("Cache-Control", "no-cache");

xhr.send(data);
                                                    

#import 

NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
                            @"Accept": @"application/json",
                            @"Authorization": @"Basic",
                            @"Cache-Control": @"no-cache",
NSArray *parameters = @[ @{ @"name": @"from", @"value": @"TestSender" },
                            @{ @"name": @"to", @"value": @"0xxxxxxxxx" },
                            @{ @"name": @"msg", @"value": @"Hello, I am testing GiantSMS bulk messaging API service" } ];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";

NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
    [body appendFormat:@"--%@\r\n", boundary];
    if (param[@"fileName"]) {
        [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
        [body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
        [body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
        if (error) {
            NSLog(@"%@", error);
        }
    } else {
        [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
        [body appendFormat:@"%@", param[@"value"]];
    }
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://giantsms.com/servicer/api/v1/send"]
                                                        cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                    timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];
                                                    

import Foundation

let headers = [
    "content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    "Accept": "application/json",
    "Authorization": "Basic",
    "Cache-Control": "no-cache",
]
let parameters = [
    [
    "name": "from",
    "value": "TestSender"
    ],
    [
    "name": "to",
    "value": "0xxxxxxxxx"
    ],
    [
    "name": "msg",
    "value": "Hello, I am testing GiantSMS bulk messaging API service"
    ]
]

let boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"

var body = ""
var error: NSError? = nil
for param in parameters {
    let paramName = param["name"]!
    body += "--\(boundary)\r\n"
    body += "Content-Disposition:form-data; name=\"\(paramName)\""
    if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
        print(error)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
    } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
    }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://giantsms.com/servicer/api/v1/send")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
    print(error)
    } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
    }
})

dataTask.resume()
                                                    

import http.client

conn = http.client.HTTPConnection("giantsms,com")

payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"from\"\r\n\r\nTestSender\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"to\"\r\n\r\n0xxxxxxxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"msg\"\r\n\r\nHello, I am testing GiantSMS bulk messaging API service\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"

headers = {
    'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    'Accept': "application/json",
    'Authorization': "Basic",
    'Cache-Control': "no-cache",
    }

conn.request("POST", "api,v1,send", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
                                                                

GET - Check Balance

Description

Get your SMS Credit balance

Request Endpoint

https://giantsms.com/servicer/api/v1/balance?username=xxxxxx&password=xxxxxxxxx

Request Type

GET

Request Parameters

Header
Content-Type optional The default (and only) response content type is application/json
Query
username required Your API client username. You can get this from your profile page or client applications (reseller) page.
password required Your API client password. You can get this from your profile page or client applications (reseller) page.

Response


    {
    "status": "true",
    "message": "104"
    }
                                                

Response Parameters

status A boolean description of the status of the request.
message Your credit balance or a text description of the status of the request.

Sample Request


    curl -X GET \
    'https://giantsms.com/servicer/api/v1/balance?username=xxxxx&password=xxxxxxx' \
    -H 'Accept: application/json' \
    -H 'Cache-Control: no-cache' \
                                                            

    $request = new HttpRequest();
    $request->setUrl('https://giantsms.com/servicer/api/v1/balance');
    $request->setMethod(HTTP_METH_GET);

    $request->setQueryData(array(
        'username' => 'xxxxx',
        'password' => 'xxxxx'
    ));

    $request->setHeaders(array(
        'Cache-Control' => 'no-cache',
        'Accept' => 'application/json'
    ));

    try {
        $response = $request->send();

        echo $response->getBody();
    } catch (HttpException $ex) {
        echo $ex;
    }
                                                        

    var client = new RestClient("https://giantsms.com/servicer/api/v1/balance?username=xxxxx&password=xxxxx");
    var request = new RestRequest(Method.GET);
    request.AddHeader("Cache-Control", "no-cache");
    request.AddHeader("Accept", "application/json");
    IRestResponse response = client.Execute(request);
                                                        

    OkHttpClient client = new OkHttpClient();

    Request request = new Request.Builder()
        .url("https://giantsms.com/servicer/api/v1/balance?username=xxxxx&password=xxxxx")
        .get()
        .addHeader("Accept", "application/json")
        .addHeader("Cache-Control", "no-cache")
        .build();

    Response response = client.newCall(request).execute();
                                                        

    var data = null;

    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;

    xhr.addEventListener("readystatechange", function () {
        if (this.readyState === 4) {
        console.log(this.responseText);
        }
    });

    xhr.open("GET", "https://giantsms.com/servicer/api/v1/balance?username=xxxxx&password=xxxxx");
    xhr.setRequestHeader("Accept", "application/json");
    xhr.setRequestHeader("Cache-Control", "no-cache");

    xhr.send(data);
                                                        

    #import 

    NSDictionary *headers = @{ @"Accept": @"application/json",
                            @"Cache-Control": @"no-cache",

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://giantsms.com/servicer/api/v1/balance?username=xxxxx&password=xxxxx"]
                                                        cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                    timeoutInterval:10.0];
    [request setHTTPMethod:@"GET"];
    [request setAllHTTPHeaderFields:headers];

    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
    [dataTask resume];
                                                        

    import Foundation

    let headers = [
        "Accept": "application/json",
        "Cache-Control": "no-cache",
    ]

    let request = NSMutableURLRequest(url: NSURL(string: "https://giantsms.com/servicer/api/v1/balance?username=xxxxx&password=xxxxx")! as URL,
                                            cachePolicy: .useProtocolCachePolicy,
                                        timeoutInterval: 10.0)
    request.httpMethod = "GET"
    request.allHTTPHeaderFields = headers

    let session = URLSession.shared
    let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
        if (error != nil) {
        print(error)
        } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
        }
    })

    dataTask.resume()
                                                        

    import http.client

    conn = http.client.HTTPConnection("giantsms,com")

    headers = {
        'Accept': "application/json",
        'Cache-Control': "no-cache",
        }

    conn.request("GET", "api,v1,send", headers=headers)

    res = conn.getresponse()
    data = res.read()

    print(data.decode("utf-8"))