> For the complete documentation index, see [llms.txt](https://help.clickatell.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.clickatell.com/developers-api-reference/developers-archive/sms-rest-api-overview/send-message.md).

# Send message

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](broken://pages/IGu1kyKq8IyGrhIPmVnS). 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
```

{% hint style="info" %}
The REST API may respond with various HTTP status codes. See the full list [here](broken://pages/sX2rvw0QeyQCuvzuQ5GC).
{% endhint %}

### **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**

{% code lineNumbers="true" %}

```
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>
```

{% endcode %}

#### **Response**

{% code lineNumbers="true" %}

```
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>
```

{% endcode %}

### **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**

{% code lineNumbers="true" %}

```
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
    }
)
```

{% endcode %}

#### **PHP**

{% code overflow="wrap" lineNumbers="true" %}

```
<?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);
?>
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.clickatell.com/developers-api-reference/developers-archive/sms-rest-api-overview/send-message.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
