Loader

Send message


Overview

This command allows you to send one or more SMS messages. To send messages to your database of mobile numbers, you can call this command in a loop.

The server will respond with a unique identifier for each message (referred to as an API message ID). This API message ID can be used to track and monitor the status of your message. You can also send to multiple handsets in one single HTTP/S request (up to 600 messages). This is useful if you are sending the same message text to all handsets.

For high volume messaging, we encourage the use of persistent (keep-alive) HTTP/S connections. Multiple concurrent HTTP/S connections may also be used for additional performance.

POST https://api.clickatell.com/rest/message

Note: the REST API may respond with various HTTP status codes. See the full list here.


JSON

Request
POST /rest/message HTTP/1.1
HOST: api.clickatell.com
X-Version: 1
Content-Type: application/json
Authorization: Bearer [Your Authorization Token]
Accept: application/json
{"text":"Test Message","to":["2799900001""2799900002"]}
 
Response
HTTP/1.1 202 Accepted
Content-Type: application/json
{
 "data":{
    "message":[
      {
       "accepted":true,
       "to":"2799900001",
        "apiMessageId":"a55b8f8d56f33440e993aa614c68bf8b"
     },
      {
       "accepted":true,
       "to":"2799900002",
       "apiMessageId":"7f1d32762f6db11f3b7d2aaca2aaf362"
     }
    ]
  }
}

XML

Request

1
2
3
4
5
6
7
8
9
10
11
12
13

POST /rest/message HTTP/1.1
HOST: api.clickatell.com
X-Version: 1
Content-Type: application/xml
Authorization: Bearer [Your Authorization Token]
Accept: application/xml
<?xml version "1.0"?>
<request>
    <data>
        <text>Test Message</text>
        <to>2799900001</to>
    </data>
</request>


Response

1
2
3
4
5
6
7
8
9
10
11
12

HTTP/1.1 202 Accepted
Content-Type: application/xml
<?xml version="1.0"?>
<response>
    <data>
        <message>
            <accepted>1</accepted>
            <to>2799900001</to>
            <apiMessageId>93f924cad9664cfbb0c6ab03a3032ef0</apiMessageId>
        </message>
    </data>
</response>


Sample code

cURL
to="[\"<mobile number>\"]"
message="Test Message"
authToken="<place auth token here>"
  
curl -X POST \
-H "X-Version: 1" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $authToken" \
-d "{\"text\":\"$message\",\"to\":$to}" \
https://api.clickatell.com/rest/message

Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

import httplib2, json
 
to=["mobile number"]
message="Test Message"
authToken = ""
 
resp, content = httplib2.Http().request(
    "https://api.clickatell.com/rest/message",
    "POST",
    body=json.dumps({
        "text":message,
        "to":to
    }),
    headers={
        "X-Version" "1",
        'Content-Type':'application/json',
        "Accept" "application/json",
        "Authorization" "Bearer " + authToken
    }
)


PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

<?php
 
$to="[\"<mobile number>\"]";
$message="Test Message";
$authToken="<place auth token here>";
 
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL,            "https://api.clickatell.com/rest/message");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,           1);
curl_setopt($ch, CURLOPT_POSTFIELDS,     "{\"text\":\"$message\",\"to\":$to}");
curl_setopt($ch, CURLOPT_HTTPHEADER,     array(
    "X-Version: 1",
    "Content-Type: application/json",
    "Accept: application/json",
    "Authorization: Bearer $authToken"
));
  
$result = curl_exec ($ch);
?>

Did you find this information informative?

Other Resources

Ask the Community

Visit Stack Overflow to join our community of developers and find the answer you need

Contact Support

Contact our support team and one of our agents will be in touch with you to answer any questions you have