Send an SMS with Cellcast RESTful API

With our SMS messaging API you can:

  1. Send SMS messages.
  2. Receive real time delivery reports (DLR) for all messages sent.
  3. Receive replies and inbound SMS messages.

Our simple REST API allows you to get up and running in minutes, just follow the helpful Quick Start guide. For advanced users, dig deeper into our technology and check our reference guides for more detailed functions and calls. We have a wide range of calls to mirror useful functionality on the site at both user and reseller level. We also offer code samples in order to make your experience using the API suite as clean as possible.

So let's now look at how to use and get the best out of the REST API.



Security

To ensure security & privacy the API only works over HTTPS protocol for all requests. Also, for your own security, If you have a website with a form which sends SMS be sure to send the request from your server and not directly from the browser otherwise you will be giving away your API secret and opening the floodgates to unwanted charges.


Authentication

All API requests require your API credentials, We will provide you APPKEY. For Security API credentials must be passed as HTTP Basic Authentication headers not as CGI parameters.


Throttling

To provide the best service to all our customers we limit the number of API calls.If you exceed this limit we will return two indicators which you can use in your code to detect that you have been throttled. The first is the HTTP status code 429 "Too Many Requests", the second is the error code "OVER_LIMIT" in the error block of the response body.


Pagination

Some responses are too large to be returned in one go so we paginate. To identify which calls use pagination look for the "page" parameters in the parameter descriptions for each API call. These calls include a "page" block in the response with two values, "count" and "number". Count tells you how many pages are available and number indicates the page number you are on. The page parameter is used to request a certain page, it defaults to 1. The max parameter is used to limit the number of results returned per page, the default is 25.


Error Reporting

Always check if your API call was successful or resulted in error. You may check the following

  1. 200 OK response header. It will be 4xx if an error occurred.
  2. error->code structure should equal to 'SUCCESS'Note that some API functions can return custom errors of their own (listed in appropriate document sections). Check the error->description for details, e.g. which field caused an error or which resource you don’t have access to.

We can't wait to see what you build!

send-sms

Base URL:

https://cellcast.com.au/api/v3/send-sms
Method: POST

Parameters

Header Parameters Description
APPKEY Please add provided APPKEY. Which is linked to your cellcast account
Content-Type application/json

SMS Data Parameters

Name Example Description
sms_text SMS Text goes here string - Required field
- To add a new line to the message, use "\r\n" in the message string with only double quote
numbers ["+61400000000"] JSON encoded Array - Required field
For multiple SMS send: ["+61400000000","+61400000001"]
You can pass 10000 numbers to send an SMS in one API call

Success Responses

Code Status Description
200 SUCCESS You will get SMS scheduled count and credit deduction count.

Success Responses looks like:

{
    "meta": {
        "code": 200,
        "status": "SUCCESS"
    },
    "msg": "Your SMS is successfully scheduled.",
    "data": {
        "total_numbers": 1,
        "success_number": "1",
        "credits_used": 1
    }
}

Error Responses

Status Code Description
AUTH_FAILED_NO_DATA 401 You have not provided APPKEY
AUTH_FAILED 401 - APPKEY you have provided is invalid
- You are not a registered user
FIELD_EMPTY 400 Required field is empty
RECIPIENTS_ERROR 400 No valid recipients left after validation or recipient in unsubscribed list.
FIELD_INVALID 400 -You can pass 10000 numbers to send an SMS in one API call
- You can send the maximum message length of 918 characters, or send a message length of 402 characters for the Unicode character set.
-You do not have enough credit to send SMS
BAD_REQUEST 400 Please provide proper data

Error Responses looks like:

{
    "meta": {
        "code": 400,
        "status": "FIELD_INVALID"
    },
    "msg": "You can send the maximum message length of 918 characters, or send a message length of 402 characters for the Unicode character set.",
    "data": []
}

PHP Code Example

You can call following function to send SMS.

Need to pass "SMS text" and "Mobile number array" parameters for this function

function sendSms($text, $phone_number) {
    try {
        $url = 'https://cellcast.com.au/api/v3/send-sms'; //API URL
        $fields = array(
            'sms_text' => $text, //here goes your SMS text
            'numbers' => $phone_number // here goes your numbers array
        );
        $headers = array(
            'APPKEY: <<APPKEY>>',
            'Accept: application/json',
            'Content-Type: application/json',
        );

        $ch = curl_init(); //open connection
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        if (!$result = curl_exec($ch)) {
            $response_error = json_decode(curl_error($ch));
            return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again", "result" => $response_error));
        }
        curl_close($ch);
        return json_encode(array("status" => 200, "msg" => "Successfully send sms", "result" => json_decode($result)));
    } catch (\Exception $e) {
        return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again.", "result" => array()));
    }
}
                                

Call Function

//Set text and mobile numbers
$text = "Hi User, This is my first SMS Test!";
$phone_number = array("<<Number1>>","<<Number2>>","<<Number3>>");

//Call function to send SMS
sendSms($text, $phone_number);
                                

get-responses

Base URL:

https://cellcast.com.au/api/v3/get-responses?page=<<page_number>>&type=sms;
Method: GET

Parameters

Header Parameters Description
APPKEY Please add provided APPKEY. Which is linked to your cellcast account
Content-Type application/json

API Parameters

Name Example Description
page Page number Pass page number.Default value is 1
type Response of SMS pass 'sms' value to get only responses of sent SMS

Success Responses

Code Status Description
200 SUCCESS You have <<Total Responses>> response(s)
Response Description
from Recipient Mobile Number that sent the reply message.
body Inbound message body.
received_at Received date and time.
original_body Original outgoing SMS message body.
original_message_id Original SMS message ID. Returned when originally sending the message.
message_id The Message ID for the inbound message.

Success Responses looks like:

{
    "meta": {
        "code": 200,
        "status": "SUCCESS"
    },
    "msg": "You have 1 response(s)",
    "data": {
        "page": {
            "count": 1,
            "number": 1
        },
        "total": "1",
        "responses": [
            {
                "from": "+614NNNNNNNN",
                "body": "Received ",
                "received_at": "2019-04-08 17:37:49",
                "original_body": "Please reply Thank You",
                "original_message_id": "4455438", // Outbound ID
                "message_id": "dba864ec-e486-4647-82c4-d0b94771080b", // Response Message ID(inbound_id)
                "subaccount_id": "" // Sub account email address
            }
        ]
    }
}

Error Responses

Status Code Description
AUTH_FAILED 400 You are not a registered user
NOT_FOUND 400 No Response are available!

Error Responses looks like:

{
    "meta": {
        "code": 401,
        "status": "AUTH_FAILED"
    },
    "msg": "APPKEY you have provided is invalid",
    "data": []
}

PHP Code Example

You can call following function to get SMS responses.

function getSmsResponses($page = 1) {
    try {
        $url = 'https://cellcast.com.au/api/v3/get-responses?page=' .$page.'&type=sms'; //API URL
        $headers = array(
            'APPKEY: <<APPKEY>>',
            'Accept: application/json',
            'Content-Type: application/json',
        );

        $ch = curl_init(); //open connection
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 4);
        if (!$result = curl_exec($ch)) {
            $response_error = json_decode(curl_error($ch));
            return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again", "result" => $response_error));
        }
        curl_close($ch);
        return json_encode(array("status" => 200, "msg" => "Successfully received", "result" => json_decode($result)));

    } catch (\Exception $e) {
        return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again.", "result" => array()));
    }
}
                                

Call Function

//Call function to get sms status function
$response_status = getSmsResponses(<<page_number>>);
                                

inbound-read

Base URL:

https://cellcast.com.au/api/v3/inbound-read
Method: POST

Parameters

Header Parameters Description
APPKEY Please add provided APPKEY. Which is linked to your cellcast account
Content-Type application/json

API Parameters

Name Example Description
message_id Response of Message ID The Message ID for the inbound message. We are consider first "message_id" parameter.
date_before Date timestamp An optional timestamp - mark all as read before this timestamp. If not given, all messages will be marked as read.

You can use one parameter at a time. If you want to change status using message_id then you just need to pass message_id. If you want to mark all as read before given timestamp then you can pass only "date_before" parameter.

You can set the status of inbound messages of your account.


Success Responses

Code Status Description
200 SUCCESS You have <<Total Responses>> response(s)

Success Responses looks like:

{
    "meta": {
        "code": 200,
        "status": "SUCCESS"
    },
    "msg": "Inbound messages have been marked as read.",
    "data": []
}

Error Responses

Status Code Description
AUTH_FAILED 400 You are not a registered user

Error Responses looks like:

{
    "meta": {
        "code": 401,
        "status": "AUTH_FAILED"
    },
    "msg": "APPKEY you have provided is invalid",
    "data": []
}

PHP Code Example

You can call following function to get SMS responses.

function setSmsInboundStatus($timestamp) {
    try {
        $url = 'https://cellcast.com.au/api/v3/inbound-read'; //API URL
        $fields = array(
            'message_id' => $message_id, //here goes your inbound message ID
        );

        // If you want to mark all inbound message as read optionally before a certain date.
        //$fields = array(
        //    'date_before' => $date_before, //here goes your inbound message ID
        //);

        $headers = array(
            'APPKEY: <<APPKEY>>',
            'Accept: application/json',
            'Content-Type: application/json',
        );

        $ch = curl_init(); //open connection
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        if (!$result = curl_exec($ch)) {
            $response_error = json_decode(curl_error($ch));
            return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again", "result" => $response_error));
        }
        curl_close($ch);
        return json_encode(array("status" => 200, "msg" => "Successfully set status", "result" => json_decode($result)));
    } catch (\Exception $e) {
        return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again.", "result" => array()));
    }
}
                                

Call Function

//Call function to get sms status function
$response_status = setSmsInboundStatus(<<message_id>>);
                                

SMS character count

Can I send messages in excess of 160 characters?

You have the capability of sending messages in excess of 160 characters through our services.

When sending a message in excess of 160 characters, the message is broken up in to message parts of 153 characters, and sent to the handset. The handset then reassembles the message, displaying the message as one extended-length, concatenated message. When sending an extended-length message you are charged for each 153 character part that is sent. This charging process is dictated by the network operators.

You can send the maximum message length of 918 characters, or send a message length of 402 characters for the Unicode character set.


What characters are part of the Unicode charset?

The Unicode character list contains symbols from the Cyrillic, Chinese, Arabic, Korean and Hangul alphabets. It also contains several special symbols (such as emoticons, emoji and kanji).

Unicode character list: here


GSM Charset: The GSM 03.38 charset is the standard character set for text messaging on GSM-based cell phones. All GSM handsets and network elements support the GSM 7-bit alphabet. The basic GSM charset contains the letters A to Z (uppercase and lowercase), numbers, special symbols and several symbols from the Greek alphabet.

@	Δ	SP	0	¡	P	¿	p
£	_	!	1	A	Q	a	q
$	Φ	"	2	B	R	b	r
¥	Γ	#	3	C	S	c	s
è	Λ	¤	4	D	T	d	t
é	Ω	%	5	E	U	e	u
ù	Π	&	6	F	V	f	v
ì	Ψ	'	7	G	W	g	w
ò	Σ	(	8	H	X	h	x
Ç	Θ	)	9	I	Y	i	y
LF	Ξ	*	:	J	Z	j	z
Ø	ESC	+	;	K	Ä	k	ä
ø	Æ	,	<	L	Ö	l	ö

Escape Characters: Some characters in the GSM 03.38 extension table can only be used at the cost of two characters. The GSM charset uses 7-bit alphabet encoding, but the escape characters require 14 bits to encode, thus taking up two characters. These symbols are:  |, ^, {, }, €, [, ~, ] and \.

Unicode Symbols: Unicode is a standard for encoding, handling and representing the text expressed in many of the world’s writing systems. The latest list of Unicode symbols contains over 120,000 characters from multiple symbol sets and 129 historic and modern scripts.

Unicode Encoding: Compared to the GSM charset, Unicode encoding supports a huge range of languages and symbols. However, if your text message contains a symbol that isn’t in the 7-bit alphabet, UCS-2 encoding must be used. This type of encoding takes up a lot of space, thus reducing the number of characters allowed in a message to 70.

Mobile format

Australian Mobile format

You can send an SMS to any Australian Mobile number.

Allocation for numbers in the range 04xy z00 000 – 04xy z99 999


Valid Mobile Numbers format:

  1. +614NNNNNNNN
  2. 04NNNNNNNN

Master List of Emojis

Master List of Emojis

Simply highlight and copy the emoji of your choice from any emoji column below. Then paste it where you want it to appear. This will work well in messages, chats, and social media posts.


"If you cannot see some emojis from the list below, we recommend using the latest version of Chrome since some emojis are part of the new release and may not be viable in your browser just yet. They will still work however if you copy and paste just like any other emoji."


*** Reminder: Unicode characters are larger in bytes and will decrease your SMS character limit from 160 to 70 ***

Master List of Emojis

Help

Contact us

Email: info@cellcast.com.au
Melbourne Head Office:
40 Porter St, Prahran, VIC 3181, Australia
Australia & NZ: +61 (03) 8560 7025


Get in touch, send us a message to arrange a coffee catch-up