Clickatell HTTP
Clickatell HTTP
Clickatell HTTP
6
17 May 2012
Content
Content............................................................................................................................................................. 1
Change history ................................................................................................................................................. 2
Overview .......................................................................................................................................................... 3
1. Introduction ............................................................................................................................................... 3
2. Getting started .......................................................................................................................................... 3
3. Basic commands ...................................................................................................................................... 5
3.1 Authentication and session IDs .......................................................................................................... 5
3.2 Ping ..................................................................................................................................................... 6
3.3 Send a message ................................................................................................................................. 6
3.4 Query a message ................................................................................................................................ 7
4. Message parameters ................................................................................................................................ 7
4.1 Table of parameters ............................................................................................................................ 7
4.2 Message parameters in detail ...........................................................................................................10
5. Additional commands .............................................................................................................................22
5.1 Delete/stop message ........................................................................................................................22
5.2 Query balance ...................................................................................................................................22
5.3 Coverage Query ................................................................................................................................22
5.4 MMS push .........................................................................................................................................23
5.5 WAP push service indication ............................................................................................................24
5.6 Get message charge query...............................................................................................................25
5.7 Token (voucher) pay .........................................................................................................................25
6. Batch messaging ....................................................................................................................................26
6.1 Start batch .........................................................................................................................................26
6.2 Sending messages to existing batch ................................................................................................26
6.3 Quick send to batch ..........................................................................................................................27
6.4 End batch ..........................................................................................................................................27
7. 8-BIT messaging .....................................................................................................................................27
8. Message examples .................................................................................................................................28
8.1 Simple examples ...............................................................................................................................28
8.2 Batch SMS examples ........................................................................................................................28
8.3 8-bit SMS examples ..........................................................................................................................29
Appendix A: Error codes ................................................................................................................................31
9. Appendix B: Message statuses ..............................................................................................................33
10.
Terminology ......................................................................................................................................34
11.
Contact details ..................................................................................................................................34
Change history
Approximately six (6) months of changes are reflected.
Visit http://www.clickatell.com/downloads/http/Clickatell_HTTP.pdf to check for updates to this document.
Version
Date
Section
Changes to Documentation
2.4.6
13 June 2012
2.4.5
19 December 2011
Appendix A
2.4.4
01 November 2011
Overview
This technical document is intended for developers who wish to use the Clickatell HTTP API for sending
messages, and describes the various programming methods and commands used by developers when
using this API.
The HTTP API is the most popular API, because there are many ways to utilise it for message sending and
it can be used for low or high-volume messaging. As HTTP is a means for relaying information, the HTTP
API can be used with practically any web-service application. This is particularly useful for high-volume
message sending.
To use this API, you need to register at (http://www.clickatell.com/register/?product=1). When you sign up
for an HTTP/S account, you will be given a username, password and api_id: keep these at hand. Once you
have registered and been activated you will receive 10 free credits with which to test our service. Messages
sent with these credits contain a canned (pre-populated) message. You can test the API using these
credits, and purchase credits to start sending your own, customised messages.
We will cover the HTTP method in this document. Additional documentation is available for the other
methods. Sample code is provided on the site.
1. Introduction
This is one of the simpler server-based forms of communication to our gateway. It can be used either in the
form of a HTTP POST, or as a URL (GET). We recommend POST for larger data transfer, due to the size
limitations of GET. Communication to our API can be done either via HTTP on port 80 or HTTPS on port
443. All calls to the API must be URL-encoded. The parameter names are case-sensitive. Batch
messaging is catered for in a variety of ways.
Note: It is important that the ENTIRE document is read before contacting support. Parameters are
case-sensitive. All examples shown use HTTP GET.
2. Getting started
In order to use the Clickatell gateway you need a Clickatell account and at least one registered connection
(API sub-product instance) between your application and our gateway. Each connection method is known
as a sub-product (of our API product). Heres how:
Step 1 - register for a Clickatell account
If you do not already have a Clickatell Central account, you need to register for one as per below. If you
have a Clickatell Central account, proceed to Step 2 for instructions on how to add an API connection to
your account.
Go to http://www.clickatell.com/products/sms_gateway.php, and choose the appropriate API sub-product
(connection method) you wish to use.
Click on the registration hyperlink.
If you have not received the activation email within a few minutes you can choose to resend it or edit the
address provided.
Once you have activated your account by clicking on the link within your activation email, you will be
directed to the login page. Once you have logged in you will be on the Clickatell Central landing page and
you can use your free SMS test credits. Please note that for security reasons these 10 credits contain preset Clickatell content.
To start sending personalised messages, you need to verify your mobile number so you can purchase
credits. The verification steps appear in the grey block at the bottom of the Clickatell Central landing page.
This block will be visible until you have verified your mobile number.
Check the mobile number that you have entered and, if it is correct, click Send Activation Code. A
verification code will be sent to your mobile number. If you would like the code to be sent to a different
number, replace the number provided and follow the same steps. Enter the verification code in the space
provided and click the Verify Now button.
When your mobile number is verified, you will be able to purchase credits and send messages. To add an
API connection, please follow the steps detailed below.
Step 2 - add a registered API connection (sub-product)
If you are not already logged into your account, then you must do so at http://www.clickatell.com/login.php
Select Manage my Products from the top menu.
Select Get Connections from the Manage my Products submenu in the left pane.
Select the API you wish to add to your account.
Complete the details.
After successfully adding a connection, a confirmation message will be displayed with a unique API ID and
information on how to get started.
The getting started section displays the API connection parameters and authentication details. These
details are required when connecting to the Clickatell gateway to send a message.
Note: For more information on managing your API connections within your Clickatell account see our API
guide at http://support.clickatell.com/guides/clickatell/api_guide.php.
3. Basic commands
In order to send a message, the system will firstly need to authenticate you as a valid user. The preferred
method of authentication is using the auth command. Whilst it involves an additional step, it is far more
secure in that you only have to pass login details once, to obtain a session ID. If you do not use auth to
obtain a session ID, you will have to pass your account details with every command.
All other commands are then made up of three segments: authentication, the basic message components
(message content and recipients) and the additional message parameters. In the examples below, we will
include the authentication and basic message components. The additional message parameters will be
included only where they are relevant.
Basic Command Structure:
URL
Call
http://api.clickatell.com/http/sendmsg?session_id=xxxx&to=xxxx&text=xxxx
or
http://api.clickatell.com/http/sendmsg?api_id=xxxx&user=xxxx&password=xxxx&to=xxxx&text=xxxx
3.1
In order to deliver a message, the system needs to authenticate the request as coming from a valid source.
We use a number of parameters to achieve this:
api_id: This is issued upon addition of an HTTP sub-product to your account. A single account
may have multiple API IDs associated with it.
user: This is the username of your account.
password: The current password you have set on your account.
Additionally we can force an IP lockdown, allowing only requests sent from IP addresses that you have
specified. This can be set under the API product preferences within your account. Please ensure that after
testing, you remove all unnecessary IP addresses in your preferences to tighten up on security.
You can have multiple sessions open, however the session ID will expire after fifteen minutes of inactivity.
You will then have to re-authenticate to receive a new session ID. Alternatively, you can ping every 10
minutes or so to ensure that the current session ID is kept live.
Command:
Not encrypted: http://api.clickatell.com/http/auth?api_id=xxxx&user=xxxx&password=xxxx
Encrypted: https://api.clickatell.com/http/auth?api_id=xxxx&user=xxxx&password=xxxx
Response:
OK: Session ID
or:
ERR: Error number, error description
This session ID must be used with all future commands to the API, unless you authenticate each time
within the command itself.
Ping
This command prevents the session ID from expiring in periods of inactivity. The session ID is set to expire
after 15 minutes of inactivity. You may have multiple concurrent sessions using the same session ID.
Command:
http://api.clickatell.com/http/ping?session_id=xxx
Response:
OK:
or:
ERR: Error number, error description
3.3
Send a message
To facilitate sending an SMS with a single command, we have included the ability to post api_id, user and
password variables in sendmsg. This is only required if you do not authenticate yourself using the
authentication command (auth). Using a session ID is preferred to authenticating each time.
One can send to multiple destination addresses by delimiting the addresses with commas. The basic
parameters required are to (the handset number to which the message is being sent) and text (the content
of the message). A maximum of 100 comma separated destination addresses per sendmsg, or quicksend
command, are possible, if you are calling the command via a GET, or alternatively, 300 destination
addresses if you are submitting via a POST.
In the examples displayed in this document we will only refer to these basic parameters. Other parameters
may be used to enable different features. These are discussed in the following section.
Each message returns a unique identifier in the form of an API message ID. This can be used to track and
monitor any given message. The API message ID (apiMsgid) is returned after each post.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxxx&to=xxxx&text=xxxx
or:
http://api.clickatell.com/http/sendmsg?api_id=xxxx&user=xxxx&password=xxxx&to=xxxx&text=xxxx
Response Single Message:
ID: apimsgid
Response Multiple Messages:
ID: apimsgid To: xxxxxx
ID: apimsgid To: xxxxxx
Or:
Response Single Message:
ERR: Error number, error description
Response Multiple Messages:
ERR: Error number, error description
ERR: Error number, error description
Query a message
This command returns the status of a message. You can query the status with either the apimsgid or
climsgid. The API Message ID (apimsgid) is the message ID returned by the Gateway when a message
has been successfully submitted. If you specified your own unique client message ID (climsgid) on
submission, you may query the message status using this value. You may also authenticate with api_id,
user and password.
See Appendix B for status codes.
Command:
http://api.clickatell.com/http/querymsg?session_id=xxx&apimsgid=XXXXX
or:
http://api.clickatell.com/http/querymsg?user=xxxx&password=xxxx&api_id=xxxx& apimsgid=XXXXX
Response:
ID: xxxx Status: xxxx
Or:
ERR: Error number, error description
Note: Clickatell can also post message status updates to your application via means of a Callback URL.
This is the recommended method to obtain message status updates as your application is not required to
continually poll the Clickatell gateway. Detailed information can be found in the Callback URL section
under Message parameters.
Message status reports can be viewed online within your Clickatell Central account. These reports can also
be exported in CSV or Excel format.
4. Message parameters
4.1
Table of parameters
There are a variety of messaging and SMS features supported by the gateway, which can be activated by
including a number of additional parameters. These parameters include those in the table below.
Parameters are case-sensitive. There are a variety of custom messaging and SMS features supported by
the gateway, which can be activated by including a number of vendor-specific TLV's. These TLV's are
displayed in the table below.
Name
Parameter
name
API product ID
api_id
Username
user
Password
password
Session ID
session_id
Short description
Default
value
Restricted
values
Name
Parameter
name
Short description
Default
value
Restricted
values
to
No 00 prefix or
leading +
symbol should
be used.
Text
text
Go to
http://www.clicka
tell.com/helpsupport/frequentl
y-askedquestions/
search for Why
do some
characters take
two spaces?
Source address
from
gateway
assigned
number
A valid
international
format number
between 1 and
16 characters
long, or an 11
character
alphanumeric
string.
Enable callback
callback
0,1,2,3,4,5,6,7
Read detailed
description of
parameter.
Delivery time
deliv_time
Concatenation
concat
Maximum credits
max_credits
As per
profiles
1,2,3
0.8,1,1.5,2,2.5,3
Name
Parameter
name
Required features
req_feat
Delivery queue
queue
1, 2,3
1 is highest
priority.
Gateway
escalation
escalate
Prompts an escalation to an
alternative route, if messages are
queued on the least-cost route.
0 - off
1 - Escalate
immediately to
an alternative
route if
messages are
queued on the
least-cost route.
Mobile originated
mo
0 Off. We use
our normal
routing rules.
1 Enable
Reply.
Client message ID
cliMsgId
Unicode message
unicode
Message type
msg_type
SMS_TE
XT
udh
Short description
Default
value
Restricted
values
Read detailed
description of
parameter.
Up to 32
alphanumeric
characters. No
spaces.
0 No Unicode
1 Send as
Unicode.
Name
Parameter
name
Data
data
Validity period
See
detailed
information
on message
parameter
Short description
Default
value
Restricted
values
1440
minutes
(24
hours)
Set value in X
minutes from 1
1440 minutes.
Default
value
Restricted
values
Parameter
name
Binary
binary
Scheduled Time
scheduled_time
Short description
4.2
4.2.1
0 - off
1 - force binary
SMS messages need to be sent in the standard international format, with country code followed by number.
No leading zero to the number and no special characters such as "+" or spaces must be used. For
example, a number in the UK being 07901231234 should be changed to 447901231234.
If have you set the preferred dial prefix preference within your client account after logging in on-line, any
mobile numbers starting with zero will have the zero stripped and replaced with your default prefix. If the
mobile number does not have a zero, the default prefix will not be changed.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx
4.2.2
Text
This is the default parameter that is used to add message content. A single text message can contain up to
160 characters or 140 bytes.
Note: If you are adding special characters to a message it can be confusing to the recipient, use the urltext
parameter instead to translate all "special" characters to their corresponding hexadecimal codes.
10
The source address (from), also known as the sender ID, can be either a valid international format number
between 1 and 16 characters long, or an 11 character alphanumeric string. These must be registered within
your online account and approved by us before they may be used. MO numbers rented from us do not
require approval
Note that characters such as spaces, punctuation, Unicode and other special characters may not always
be supported to all destinations and could interfere with your delivery. We suggest that you refrain from
using such characters on the source address. If this is set, then delivery acknowledgements may be
unavailable. The use of an alphanumeric source address with 8-bit messaging may cause message failure.
This service is not guaranteed across all mobile networks and may interfere with delivery to certain
handsets.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&from=xxxx
Note: To ensure that this feature is supported when delivering your message, the required features
(req_feat) parameter for this feature must be set.
4.2.4
In order to determine whether an SMS has been received by a handset or not, we request delivery
acknowledgement for every message we send. The ability to receive reliable delivery acknowledgements
varies between mobile networks. Please test to a specific mobile network first, before assuming that you
will receive handset acknowledgments for messages that are delivered.
If a GSM handset is absent, e.g. switched off or out of coverage, the SMS will be delivered according to a
retry cycle once the handset is back in coverage. A delivery receipt will only be returned if and when the
retry is delivered. If the validity period or retry cycle (typically 24 hours) is exceeded, the SMS will fail and
show Error Delivering Message or status 8.
A delivery acknowledgment can be monitored via the callback URL or online reports.
4.2.5
Final or intermediary statuses are passed back by the API depending on the callback value set in the
original post. This is done by means of:
HTTP GET
HTTP POST
XML GET
XML POST
SOAP GET
SOAP POST
11
The callback URL and optional Username and Password authentication parameters can be set in the
preferences section of the particular API product within your client account, after logging in online. The URL
must begin with either http:// (non-encrypted) or https:// (encrypted). These are NOT your Clickatell
username and password but are a username and password of your choice to add additional security.
The variables returned are apiMsgId, cliMsgId, to, timestamp, from, status and charge.
Callback
value
003
final
and
error
Examples
-
HTTP
12
XML
<?xml version="1.0"?>
<callback>
<apiMsgId>996411ad91fa211e7d17bc873aa4a41d</apiMsgId>
<cliMsgId></cliMsgId>
<timestamp>1218008129</timestamp>
<to>279995631564</to>
<from>27833001171</from>
<charge>0.300000</charge>
<status>004</status>
</callback>
SOAP
With the SOAP callback method, a SOAP packet will be sent with a parameter called data. Below is an
example packet that will be sent to you via GET or POST.
Example of a SOAP packet that will be sent to you via GET or POST:
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="mt_callback">
<SOAP-ENV:Body>
<tns:mt_callback xmlns:tns="mt_callback">
<api_id xsi:type="xsd:int">1234</api_id>
<apimsgid xsi:type="xsd:string">2e838df2ee3ea418272ae05aaf84ce5d</apimsgid>
<climsgid xsi:type="xsd:string">abc123</climsgid>
<to xsi:type="xsd:string">27999123456</to>
<from xsi:type="xsd:string">27999000224</from>
<timestamp xsi:type="xsd:int">1213690834</timestamp>
<status xsi:type="xsd:int">003</status>
<charge xsi:type="xsd:float">0.300000</charge>
13
</tns:mt_callback>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This is an example callback URL that will be sent to your application:
http://www.yoursite.com/your_url.php?data=<?xml version="1.0" encoding="ISO-8859-1"?><SOAPENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="mt_callback"><SOAP-ENV:Body>
<tns:mt_callback xmlns:tns="mt_callback"><api_id xsi:type="xsd:int">1234</api_id>
<apimsgid xsi:type="xsd:string">2e838df2ee3ea418272ae05aaf84ce5d</apimsgid><climsgid
xsi:type="xsd:string">abc123</climsgid><to xsi:type="xsd:string">27999123456</to>
<from xsi:type="xsd:string">27999000224</from><timestamp
xsi:type="xsd:int">1213690834</timestamp><status xsi:type="xsd:int">003</status>
<charge xsi:type="xsd:float">0.300000</charge></tns:mt_callback></SOAP-ENV:Body></SOAPENV:Envelope>
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&callback=3
or, with encryption:
https://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&callback=3
4.2.6
The delivery of an SMS message may be delayed by setting an amount of time in minutes relative to the
time at which it was received by our gateway. We will store the message until the required time frame has
elapsed. The maximum delay time is 10080 minutes or 7 days.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&deliv_time=120
Response:
ID: xxxxx
or
ERR: Error number, error description
When sending batches of messages, the delivery time should be set in the startbatch command. This will
ensure that all messages are delivered X minutes after being posted to the Gateway.
4.2.7
Concatenation (concat)
If this value is set to 1, 2 or 3 the message will span across 1, 2 or 3 SMS messages where applicable.
One text SMS will be sent for every 160 characters or 140 bytes. If a message is concatenated, it reduces
the number of characters contained in each message by 7. With 8-bit concatenated messages, each SMS
can support up to 140 bytes including the UDH headers.
14
Status
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&concat=2
4.2.8 Maximum credits (max_credits)
This parameter overrides the maximum charge associated with message delivery, as set by the profiles
selected within your client account after logging in online. This parameter can be used to limit the cost of a
message to a particular value and is bound by the maximum credit value specified in your profiles.
A valid API message ID can still be returned for messages that are not delivered as a result of the
maximum credits value set. These messages will have a status of routing error (009).
The credit value in this parameter can be set to any amount of credits. To set your delivery profile, go to
Central>>My Settings>>Routing Profiles.
4.2.9 Required features (req_feat)
This parameter specifies the features that must be present in order for message delivery to occur. If all
features are not present, the message will not be delivered. This prevents SMS messages arriving at a
destination via the least-cost gateway, without certain features. This would, for instance, prevent the
dropping of an sender ID.
This means that we will not route messages through a gateway that cannot support the required features
you have set. For certain message types, we always set the required feature bitmask where relevant.
These are FEAT_8BIT, FEAT_UDH, FEAT_UCS2 and FEAT_CONCAT.
This parameter is set using a combined decimal number to refer to the additional required features.
E.g.: 32 + 512 = 544 Numeric sender ID and Flash SMS both required.
The value you would set to ensure that Flash and numeric sender ID are both supported, would therefore
be 544.
To ensure that delivery acknowledgment and alphanumeric IDs are supported you would use the value
8240 (16 + 32 + 8192).
15
Hex value
Decimal
Feature
Description
0x0001
FEAT_TEXT
0x0002
FEAT_8BIT
0x0004
FEAT_UDH
0x0008
FEAT_UCS2
0x0010
16
FEAT_ALPHA
0x0020
32
FEAT_NUMER
0x0200
512
FEAT_FLASH
Flash messaging.
0x2000
8192
FEAT_DELIVACK
Delivery acknowledgments.
0x4000
16384
FEAT_CONCAT
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&req_feat=####
16
Status
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&queue=2
4.2.11 Gateway escalation (escalate)
By default, the message router will select the lowest cost route (matching features and reliability) that is
available for a given destination.
This parameter ensures that, should a message be delayed due to gateway congestion or some other
reason on the initial gateway selected by our router, then alternative routes that match the required
features will be sought. This is done by moving through the available gateways in order of increasing cost,
up to the maximum charge set by the user either using the parameter that defines the maximum credits or
based on the profiles selected.
When urgent and high priority messages are sent, they should be posted with escalate set to 1 (on),
combined with a high maximum credit value to ensure that the greatest number of gateways are
available.
Values set are:
Value
Status
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&escalate=1
17
Status
Enables reply ability. We route via a pre-defined carrier to enable the ability to
reply.
It is important that the user specifies the correct from parameter together with this parameter. If no from
parameter is specified, we will use a default originator number as set by Clickatell. You will NOT receive
these replies.
If you specify the originator (the purchased mo number), then we will route the message such that it can be
replied to by the recipient. This reply will be sent to you.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&mo=#
4.2.13 Client message ID (climsgid)
This parameter is set by the user to enable internal message tracking. It allows the user to set their own
tracking ID for each message. Once set for a given message, this may be used in place of the Clickatell
issued API message ID (apimsgid) for querying message.
A client message ID (climsgid) may be any combination of alphanumeric characters excluding spaces. A
maximum of 32 characters may be used.
Client message IDs may be used with the querymsg command.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&climsgid=xxxx
18
Status
We provide a converter to convert text to Unicode within your client account online. Go to Converters from
within your account online.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&unicode=1
Eg.: becomes: .&text=03A903A80398&unicode=1
19
Description
SMS_TEXT
SMS_FLASH
SMS_NOKIA_OLOGO
SMS_NOKIA_GLOGO
SMS_NOKIA_PICTURE
SMS_NOKIA_RINGTONE
SMS_NOKIA_RTTL
SMS_NOKIA_CLEAN
SMS_NOKIA_VCARD
SMS_NOKIA_VCAL
Command:
Please see the messaging examples at the end of this document.
4.2.16 Validity period (validity)
A message may be given a time frame for which it is valid. After this period the message will expire. This
parameter takes an amount of time in minutes relative to the time at which the message was received by
our gateway. If the message is queued on our gateway for a period exceeding the validity period set then a
routing error of 115 will be returned. The default validity period is 1440 minutes (24 hours).
Note: The validity period is not passed on to the upstream gateway.
Command:
http://api.clickatell.com/http/sendmsg?session_id=xxx&to=xxxx&text=xxxx&validity=120
20
4.2.18 Binary
If this value is set to 1, the parameter will force the message data as binary (8-bit) data.
Our API will only handle a message as 8bit depending on what values has been set in your UDH data. To
ensure that your message is sent as 8bit, this parameter can be used. This can also be used when you
have no UDH data with a hex string.
Values set are:
Value
Status
Command:
http://api.clickatell.com/http/sendmsg.php?api_id=2995013&user=xyz&password=xyz&to=279991122334&
udh=040402F1F2& data=000102030405060708090A0B0C0D0E0F&binary=1
21
5. Additional commands
5.1
Delete/stop message
This enables you to stop the delivery of a particular message. This command can only stop messages
which may be queued within our router, and not messages which have already been delivered to a SMSC.
This command is therefore only really useful for messages with deferred delivery times.
Command:
http://api.clickatell.com/http/delmsg?session_id=xxx&apimsgid=XXXXX
or:
http://api.clickatell.com/http/delmsg?session_id=xxx&climsgid=XXXXX
Response:
ID: xxxx Status: xxxx
or:
ERR: Error number, error description
5.2
Query balance
This will return the number of credits available on this particular account. The account balance is returned
as a floating point value.
Command:
http://api.clickatell.com/http/getbalance?session_id=xxx
or
http://api.clickatell.com/http/getbalance?api_id=xxx&user=xxx&password=xxx
Response:
Credit: xxxx.x
or:
ERR: Error number, error description
5.3
Coverage Query
This command enables users to check our coverage of a network or number, without sending a message
to that number. Authentication is required for this API call. This call should NOT be used before sending
each message.
Command:
http://api.clickatell.com/utils/routeCoverage.php?session_id=xxxx&msisdn=xxxx
or:
http://api.clickatell.com/utils/routeCoverage.php?api_id=xxx&user=xxx&password=xxxx&msisdn=xxxx
Where msisdn is the number you wish to route to.
Response:
OK: This prefix is currently supported. Messages sent to this prefix will be routed. Charge: 1
Or:
22
5.4
MMS push
When an MMS message is sent to a phone, the mobile device receives an MMS notification message via
SMS. When this MMS notification message is received by the mobile device, the mobile device
automatically initiates a WAP gateway connection to download the content of the MMS message, from a
URL specified in the SMS notification message. This command enables users to send an MMS notification
message. Authentication is required for this API call.
MMS documentation (WAP-209-MMSEncapsulation-20020105-a.pdf, Version 05-Jan-2002) can be found
at http://www.openmobilealliance.org/tech/affiliates/wap/wapindex.html.
Default
value
Restricted
value
Parameter
Description
Example
Required
mms_subject
Subject
My+message
mms_class
Class
80
80 (Personal)
81
(Advertisement)
82 (Informational)
83 (Auto)
yes
mms_expire
3000
Time in seconds
yes
mms_from
From text
John
yes
mms_url
http://www.mywebsite.
com/example.mms
yes
yes
Command:
http://api.clickatell.com/mms/ind_push.php?user=xxxx&api_id=xxxx&password=xxxx&to=xxxx&from=xxxx&
mms_subject=xxxx&mms_class=xx&mms_expire=xxxx&mms_from=xxxx&mms_url=http://xxxx.xx/xx.mms
Response:
ID: xxxx To: xxxx
or:
ERR: Error number, error description
23
WAP Push Service Indication (SI) is a WAP address embedded within the header of a specially formatted
SMS. This is displayed as an alert message to the user, and gives the user the option of connecting directly
to a particular URL via the handsets WAP browser (if supported). This command enables you to send a
WAP Push Service Indication.
Please note: Incorrect date formats for si_created and si_expires may lead to handsets discarding messages with
delivery receipts.
Default
value
Restricted
values
Parameter
Description
Required
si_id
si_url
http://www.65mydomain.c
om?picture=6566
Yes
si_text
Notification text.
Provides a means to
specify additional
information.
Yes
si_created
A date in UTC
(Coordinated Universal
Time) format. Used to
specify the date and
time associated with the
creation or last
modification of the
content indicated by the
URL, which may differ
from the date and time
when the SI was
created.
2008-01-01T19:30:41Z
No
si_expires
2008-12-12T19:30:40Z
No
si_action
Yes
signalmedium,
signal-none,
signal-low,
signalmedium,
signal-high,
delete.
No
24
Command:
http://api.clickatell.com/mms/si_push?api_id=xxxx&user=xxxx&password=xxxx&to=xxxx&si_id=xxxx&si_url
=xxxx&si_created=xxxx&si_expires=xxxx&si_action=xxxx&si_text=xxxx
Response:
ID: xxxx To: xxxx
or:
ERR: Error number, error description
5.6
This command enables the user to query both the status and charge of a delivered message in a single
API call. You can query the status with either the apimsgid or climsgid.
Authentication is required for this API call and will only work for messages less than 15 days old. Clickatell
can also post the message charge to your application via means of a Callback URL (this is the preferred
method). Detailed information can be found in the Callback URL section under Message parameters.
Command: (query with apiMsgId)
http://api.clickatell.com/http/getmsgcharge?session_id=xxxx&apimsgid=xxxxx
or:
http://api.clickatell.com/http/getmsgcharge?api_id=xxxx&user=xxxx&password=xxxx&apimsgid=xxxxx
Response:
apiMsgId: xxxx charge: xxx status: xxx
or:
ERR: Error number, error description
Command: (query with cliMsgId)
http://api.clickatell.com/http/getmsgcharge?session_id=xxxx&climsgid=xxxxx
or:
http://api.clickatell.com/http/getmsgcharge?api_id=xxxx&user=xxxx&password=xxxx&climsgid=xxxxx
Response:
cliMsgId: xxxx charge: xxx apiMsgId: xxxx status: xxx
or:
ERR: Error number, error description
5.7
This command allows you to spend a voucher that has been generated, within your client account, after
logging in online. This is very useful for topping up sub-users accounts with credits. You would generate a
session ID for the sub-user account, into which you wish to add the credits. You may also use the standard
login details. The voucher number is currently a 16 digit numeric value.
Command:
http://api.clickatell.com/http/token_pay?session_id=xxx&token=xxxxxxxxxxxxxxxxxxxx
or
http://api.clickatell.com/http/token_pay?api_id=xxx&user=xxx&password=xxxx&token=xxxxx
25
Response:
OK: 605 - If the transaction was successful
Or:
ERR: Error number, error description
ERR: Error number, error description
6. Batch messaging
This facility enables one to do high volume delivery and server-side message merging. It offers the enduser the ability to define all elements common to a batch, and then send only the parameters that change
on a message by message basis.
One initially defines a batch using the startbatch command, which will return a unique batch ID. You then
use either senditem or quicksend with the batch ID, depending on whether the message needs to be
personalised. See SMS examples below.
Hi #field1#, your doctors appointment is at #field2# tomorrow, could become:
Hi Fred, your doctors appointment is at 10:30 tomorrow.
Hi Jane, your doctors appointment is at 14:00 tomorrow.
6.1
Start batch
Once you have issued this command, you will be returned a batch ID that is to be used when sending
multiple batch items. Included functionality also allows for message merging where you can substitute
fields that you have defined in your template. The field names are called field1 though to fieldN.
This command can take all the parameters of sendmsg, with the addition of a template, and the exception
of both the destination address and the text fields. The template parameter must be URL encoded. It must
be used before either the senditem or quicksend command.
Command:
http://api.clickatell.com/http_batch/startbatch?session_id=xxx&...............&template=Hi
balance is #field2#.&from=Sender&deliv_ack=1
#field1#,
your
Response:
ID: batch id
or:
ERR: Error number, error description
6.2
Note: The fields 1-N that you defined in the startbatch command are used to optionally personalise the
message.
Command:
http://api.clickatell.com/http_batch/senditem?session_id=xxx&batch_id=xxx&to=123456789&field1=Joe&fie
ld2=$150........
Response:
ID: apimsgid
26
6.3
Where one has the requirement to send the same message to multiple recipients, you can use the
quicksend command. This command offers low overhead and maximum throughput. It is essentially a
reference to a predefined template and a string of destination addresses.
Command:
http://api.clickatell.com/http_batch/quicksend?session_id=xxx&batch_id=xxx&to=123456789,234567890,34
5678901,etc
Response:
ID: apimsgid To: xxxxx
or:
ERR: Error number, error description
Note: A response is returned for each destination address on a new line. The newline character (\n) is
used to create the line break.
6.4
End batch
This command ends a batch and is not required (following a batch send). Batches will expire automatically
after 24 hours.
Command:
http://api.clickatell.com/http_batch/endbatch?session_id=xxx&batch_id=xxx
Response:
OK
or:
ERR: Error number, error description
7. 8-BIT messaging
Through the HTTP interface, one is also able to send 8-bit messages. These are most often used for
ringtones and logos, but one can also send vCards, vCalendar appointments and EMS messages. When
sending 8-bit messages, you need to set the user data header (UDH) of the SMS as well as sending the
data. If you are comfortable with the creation of your own UDH, we also enable you to set it directly using
the udh parameter. To simplify the process, we have provided a number of pre-defined message types
(see the msg_type parameter).
With the standard text parameter, line breaks are automatically inserted. The parameter data, is thus used
for 8-bit messaging.
Example
api_id:1234
user:xxxxxxxxx
password:xxxxxxxxxxx
27
8. Message examples
Here are some example URLs that demonstrate how to use the API. All values in these examples should
be replaced by your own values.
8.1
Simple examples
8.2
8.2.1
http://api.clickatell.com/http_batch/startbatch?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&template
=Hi+%23field1%23+this+is+a+personalised+message
28
http://api.clickatell.com/http_batch/senditem?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&batch_id=
f677d2fbb858a79aad0556dc71dd4383&to=1234567890&field1=David
http://api.clickatell.com/http_batch/senditem?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&batch_id=
f677d2fbb858a79aad0556dc71dd4383&to=2345678901&field1=John
8.2.3 Sending multiple SMS using batches
http://api.clickatell.com/http_batch/quicksend?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&batch_id
=f677d2fbb858a79aad0556dc71dd4383&to=1234567890,2345678901,3456789012,4567890123,5678901
234
8.3
Note: You cannot set an alphanumeric Sender ID (from parameter) when sending 8-bit messages.
8.3.1
Sending a ringtone
http://api.clickatell.com/http/sendmsg?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&to=1234567890
&msg_type=SMS_NOKIA_OLOGO&text=00480e010FC0000000000000003FF000000000000000
70380F9B006000001B601818DB006000C01BCF0C3058006000C01BDF8C301B3E66F9EF9BDF8C301B
626C8CD8DBDF8C301B60787CDFDBCF0C305B6078CCD81B601818DB626C8CD8DB70380F9B3E66F
CEF9B3FF0000000000000000FC000000000000000000000000000000000
8.3.3
http://api.clickatell.com/http/sendmsg?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&to=1234567890
&msg_type=SMS_NOKIA_CLEAN&text=00
8.3.4
Sending a VCARD
http://api.clickatell.com/http/sendmsg?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&to=1234567890
&msg_type=SMS_NOKIA_VCARD&text=BEGIN%3AVCARD%0D%0AVERSION%3A2.1%0D%0AN%3ABl
oggs%3BJoe%0D%0ATEL%3BPREF%3A%2B1234567890%0D%0AEND%3AVCARD%0D%0A
8.3.5
Sending a VCAL
http://api.clickatell.com/http/sendmsg?session_id=e74dee1bbed22ee3a39f9aeab606ccf9&to=1234567890
&msg_type=SMS_NOKIA_VCAL&text=BEGIN%3AVCALENDAR%0D%0AVERSION%3A1.0%0D%0ABEG
IN%3AVTODO%0D%0ACATEGORIES%3AMISCELLANEOUS%0D%0ASUMMARY%3AMeet+buyers+at+
29
30
The following list of error messages are generated by the Clickatell gateway during a validation phase
before we accept the message. These error messages are sent back to your application. There will be no
message charge if these errors are generated when sending a message. Data regarding messages that do
not pass initial validation will not be included in your Clickatell Central reports.
Number
Description
001
Authentication failed
002
Unknown username or
password
003
Session ID expired
004
Account frozen
005
Missing session ID
007
IP Lockdown violation
101
102
103
104
105
106
107
Empty message
108
109
Missing message ID
110
111
Invalid protocol
112
113
Detail
31
114
115
Message expired
116
120
121
122
123
Invalid Sender ID
128
Number delisted
130
Maximum MT limit
exceeded until <UNIX
TIME STAMP>
201
Invalid batch ID
202
No batch template
301
No credit left
302
901
Internal error
Please retry
32
Hex
Description
Detail
001
0x001
Message unknown
002
0x002
Message queued
003
0x003
Delivered to gateway
004
0x004
Received by recipient
005
0x005
006
0x006
007
0x007
008
0x008
OK
009
0x009
Routing error
010
0x00A
Message expired
011
0x00B
012
0x00C
Out of credit
014
0x00E
Maximum MT limit
exceeded
33
10. Terminology
Mobile originated (MO): A message sent (originating) from a mobile handset to an application via
Clickatell.
Mobile terminated (MT): A message sent from an application to (terminating on) a mobile handset
via Clickatell.
Premium rated message (MO): A mobile user is charged a premium for the message that they
send to a particular short or long code. This service is not available in all regions; please contact an
Account Manager for more information.
Revenue share: This refers to the portion of the premium charge associated with a premium rated
message, which is passed on to the content provider.
Content provider: This is the Clickatell customer who is offering one or more services that are
usually premium rated SMS system.
Customer: A registered Clickatell customer utilising the Clickatell API for message delivery and
receipt.
Sender ID: The from address that appears on the users handset. This is also known as the
message originator or source address. A Sender ID must be registered within your account and
approved by us before it may be used.
Destination address: The mobile number/MSISDN of the handset to which the message must be
delivered. The number should be in international number format, e.g. country code + local mobile
number, excluding the leading zero (0).
Source address: See Sender ID above.
Short code: A short number which is common across all the operators for a specific region.
Subscriber: The mobile network subscriber who owns the mobile number (MSISDN) which will
send or receive SMSs, or be billed for premium rated services.
Upstream gateway: A network operator, third party or our own short message service centre
(SMSC).
--- 0 ---
34