Send a message

To send an SMS message through the API, simply call this endpoint. Ensure the required parameters are included in your request to successfully send a message. Below are the key details:

Endpoint
POST https://api.cloudware.chat/v1/sms/send
Request parameters
  • to
    (string, required): The recipient's phone number, formatted with the country code (e.g., 2348012345678).
  • message
    (string, required): The SMS message content. Maximum length depends on character encoding.
  • from
    (string, optional): The ID of the sender.
curl -X POST "https://api.cloudware.chat/v1/sms/send" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "to": "recipient_number",
  "message": "Your message here"
}'
import requests import json url = "https://api.cloudware.chat/v1/sms/send" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" } data = { "to": "recipient_number", "message": "Your message here" } response =
requests.post(url, headers=headers, data=json.dumps(data))
$url = "https://api.cloudware.chat/v1/sms/send";
$headers = [
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
    "Content-Type: application/json"
];

$data = [
    "to" => "recipient_number",
    "message" => "Your message here"
];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
Response

The API will return a JSON response similar to the following:

{
    "data": {
        "id": "12345",
        "name": "Example Resource",
        "description": "This is an example resource.",
        "created_at": "2023-01-01T00:00:00Z",
        "updated_at": "2023-01-01T00:00:00Z"
    },
    "status": "success"
}

Receive a message

To enable your app to be notified automatically when a message is received, you need to set up a webhook.

A webhook is a URL endpoint that your application provides to receive real-time notifications or callbacks from the server. Once configured, the server will send an HTTP POST request to your webhook URL whenever a new message is received, delivering the relevant data. This allows your app to process or respond to incoming messages seamlessly.

To set up a webhook, you need to provide the URL endpoint where you want to receive the notifications. You can set up a webhook URL in the Webhooks section.

Request

Will be sent a POST request with Content-Type: application/json to the url you set in the webhook section

Body
{
  "type": "message_received", // message_received, message_sent
  "from": "1234567890", // device that sent the message
  "to": "0987654321", // number that received the message
  "message": "Hello, World!",
  "message_id": "1234567890",
  "created_at": "2020-01-01T00:00:00Z",
  "sent_at": "2020-01-01T00:00:00Z"
}

Get a list of received messages

To retrieve a list of received messages, you can call the endpoint below. The API will return a JSON response containing the list of messages received by your application.

Endpoint
GET https://api.cloudware.chat/v1/sms/messages
Request parameters
  • to
    (string, required): The recipient's phone number, formatted with the country code (e.g., 2348012345678).
  • message
    (string, required): The SMS message content. Maximum length depends on character encoding.
  • from
    (string, optional): The ID of the sender.
curl "https://api.cloudware.chat/v1/sms/messages" \ 
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests url = "https://api.cloudware.chat/v1/sms/messages" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", } response = requests.get(url, headers=headers)
$url = "https://api.cloudware.chat/v1/sms/messages";
$headers = [
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
]; 
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url); // Set the URL
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Set the HTTP headers
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return response as string

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
Response

The API will return a JSON response similar to the following:

// list of sms messages
{
    "query": "device_id=2254&phone=+40722000000", // the query used to filter the messages
    "data": [
        {
            "type": "message_received", // message_received, message_sent
            "from": "1234567890", // device that sent the message
            "to": "0987654321", // number that received the message
            "message": "Hello, World!",
            "message_id": "1234567890",
            "created_at": "2020-01-01T00:00:00Z",
            "sent_at": "2020-01-01T00:00:00Z"
        },
        ...
    ],
    "next_page": "https://api.cloudware.chat/v1/sms/messages?token=TOKEN_FOR_NEXT_PAGE", // url to the next page
}
 

Queue a message

To queue an SMS message through the API, simply call this endpoint. Ensure the required parameters are included in your request to successfully send a message. Below are the key details:

Endpoint
POST https://api.cloudware.chat/v1/sms/queue
Request parameters
  • to
    (string, required): The recipient's phone number, formatted with the country code (e.g., 2348012345678).
  • message
    (string, required): The SMS message content. Maximum length depends on character encoding.
  • from
    (string, optional): The ID of the sender.
curl -X POST "https://api.cloudware.chat/v1/sms/send" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "to": "recipient_number",
  "message": "Your message here"
}'
import requests import json url = "https://api.cloudware.chat/v1/sms/send" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" } data = { "to": "recipient_number", "message": "Your message here" } response =
requests.post(url, headers=headers, data=json.dumps(data))
$url = "https://api.cloudware.chat/v1/sms/send";
$headers = [
    "Authorization: Bearer YOUR_ACCESS_TOKEN",
    "Content-Type: application/json"
];

$data = [
    "to" => "recipient_number",
    "message" => "Your message here"
];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
Response

The API will return a JSON response similar to the following:

{
    "data": {
        "id": "12345",
        "name": "Example Resource",
        "description": "This is an example resource.",
        "created_at": "2023-01-01T00:00:00Z",
        "updated_at": "2023-01-01T00:00:00Z"
    },
    "status": "success"
}