Skip to content

Send Message ​

Send a text message to a WhatsApp number.

POST /api/v1/messages/send

Request ​

Headers ​

HeaderRequiredDescription
AuthorizationYesBearer YOUR_API_KEY
Content-TypeYesapplication/json
X-TENANT-IDNoTenant ID (if multi-tenant)

Body Parameters ​

ParameterTypeRequiredDescription
whatsapp_account_idstringYesWhatsApp account ID to send from — Dashboard → WhatsApp Numbers → API ID:
phonestringYesRecipient phone number with country code (e.g., +966501234567)
message_typestringYesMust be text
dataobjectYesMessage data object
data.textstringYesMessage text content (supports Unicode and Arabic)
scheduled_atstringNoISO 8601 datetime to schedule delivery (e.g., 2026-05-01T10:00:00). Must be in the future.
timezonestringNoIANA timezone for interpreting scheduled_at (e.g., Asia/Riyadh). Defaults to UTC if omitted.

Example Request ​

bash
curl -X POST https://cubeconnect.io/api/v1/messages/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "whatsapp_account_id": "YOUR_WHATSAPP_ACCOUNT_ID",
    "phone": "+966501234567",
    "message_type": "text",
    "data": {
      "text": "Hello! Your order #1234 has been shipped."
    }
  }'
php
$response = Http::withToken('YOUR_API_KEY')
    ->post('https://cubeconnect.io/api/v1/messages/send', [
        'whatsapp_account_id' => env('CUBECONNECT_WHATSAPP_ACCOUNT_ID'),
        'phone'        => '+966501234567',
        'message_type' => 'text',
        'data'         => [
            'text' => 'Hello! Your order #1234 has been shipped.',
        ],
    ]);
javascript
const response = await fetch('https://cubeconnect.io/api/v1/messages/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    whatsapp_account_id: process.env.CUBECONNECT_WHATSAPP_ACCOUNT_ID,
    phone: '+966501234567',
    message_type: 'text',
    data: {
      text: 'Hello! Your order #1234 has been shipped.',
    },
  }),
})

const result = await response.json()
python
import requests

response = requests.post(
    'https://cubeconnect.io/api/v1/messages/send',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'whatsapp_account_id': 'YOUR_WHATSAPP_ACCOUNT_ID',
        'phone': '+966501234567',
        'message_type': 'text',
        'data': {
            'text': 'Hello! Your order #1234 has been shipped.',
        },
    },
)

Scheduled Message Example ​

bash
curl -X POST https://cubeconnect.io/api/v1/messages/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "whatsapp_account_id": "YOUR_WHATSAPP_ACCOUNT_ID",
    "phone": "+966501234567",
    "message_type": "text",
    "data": {
      "text": "Your appointment is tomorrow at 10:00 AM."
    },
    "scheduled_at": "2026-05-01T10:00:00",
    "timezone": "Asia/Riyadh"
  }'
php
$response = Http::withToken('YOUR_API_KEY')
    ->post('https://cubeconnect.io/api/v1/messages/send', [
        'whatsapp_account_id' => env('CUBECONNECT_WHATSAPP_ACCOUNT_ID'),
        'phone'               => '+966501234567',
        'message_type'        => 'text',
        'data'                => ['text' => 'Your appointment is tomorrow at 10:00 AM.'],
        'scheduled_at'        => '2026-05-01T10:00:00',
        'timezone'            => 'Asia/Riyadh',
    ]);
javascript
const response = await fetch('https://cubeconnect.io/api/v1/messages/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    whatsapp_account_id: process.env.CUBECONNECT_WHATSAPP_ACCOUNT_ID,
    phone: '+966501234567',
    message_type: 'text',
    data: { text: 'Your appointment is tomorrow at 10:00 AM.' },
    scheduled_at: '2026-05-01T10:00:00',
    timezone: 'Asia/Riyadh',
  }),
})

Response ​

Immediate Delivery 202 Accepted ​

The message has been queued for delivery. Use webhooks to track delivery status.

json
{
  "success": true,
  "data": {
    "status": "queued",
    "message_log_id": 4521,
    "conversation_category": "SERVICE",
    "cost": 0.0,
    "scheduled_at": null
  }
}

Scheduled Delivery 202 Accepted ​

json
{
  "success": true,
  "data": {
    "status": "scheduled",
    "message_log_id": 4521,
    "conversation_category": "SERVICE",
    "cost": 0.0,
    "scheduled_at": "2026-05-01T07:00:00Z"
  }
}
FieldTypeDescription
data.statusstringqueued for immediate, scheduled for deferred delivery
data.message_log_idintegerUnique log ID for tracking
data.conversation_categorystringWhatsApp conversation category: SERVICE, MARKETING, UTILITY, AUTHENTICATION
data.costnumberMessage cost (reserved for future billing)
data.scheduled_atstring|nullUTC datetime of scheduled delivery, or null

Error Responses ​

401 Unauthorized

json
{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "Invalid API key."
  }
}

422 Unprocessable Entity

json
{
  "success": false,
  "error": {
    "code": "NO_ACTIVE_ACCOUNT",
    "message": "No active WhatsApp account found."
  }
}

429 Too Many Requests

json
{
  "success": false,
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded for your current plan."
  }
}

Phone Number Format ​

Phone numbers must include the country code without the + prefix or with it:

FormatValid
+966501234567Yes
966501234567Yes
0501234567No (missing country code)

Message Delivery Flow ​

Your API Request → CubeConnect Queue → WhatsApp Cloud API → Recipient
                         ↓
                   Message Log Created
                   (status: queued)
                         ↓
                   Webhook: status sent
                         ↓
                   Webhook: status delivered
                         ↓
                   Webhook: status read

24-Hour Messaging Window

Text messages can only be sent within 24 hours of the customer's last message. Outside this window, you must use a pre-approved template.


Get Message Status ​

Retrieve the current delivery status of a previously sent message.

GET /api/v1/messages/{id}

The {id} is the message_log_id returned when you sent the message.

Request ​

Headers ​

HeaderRequiredDescription
AuthorizationYesBearer YOUR_API_KEY

Path Parameters ​

ParameterTypeDescription
idintegerThe message_log_id returned by POST /api/v1/messages/send

Example Request ​

bash
curl -X GET https://cubeconnect.io/api/v1/messages/4521 \
  -H "Authorization: Bearer YOUR_API_KEY"
php
$response = Http::withToken('YOUR_API_KEY')
    ->get('https://cubeconnect.io/api/v1/messages/4521');
javascript
const response = await fetch('https://cubeconnect.io/api/v1/messages/4521', {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
})
const result = await response.json()

Response ​

200 OK

json
{
  "success": true,
  "data": {
    "message_log_id": 4521,
    "status": "delivered",
    "to_phone": "966501234567",
    "message_type": "text",
    "meta_message_id": "wamid.HBgN...",
    "sent_at": "2026-05-01T07:05:00Z",
    "scheduled_at": null,
    "cost_amount": 0.0,
    "cost_currency": "SAR",
    "error_message": null,
    "created_at": "2026-05-01T07:00:00Z"
  }
}
FieldTypeDescription
message_log_idintegerUnique message ID
statusstringCurrent delivery status (see table below)
to_phonestringRecipient phone number
message_typestringtext or template
meta_message_idstring|nullWhatsApp message ID (set after sending)
sent_atstring|nullUTC datetime when sent to WhatsApp
scheduled_atstring|nullUTC datetime of scheduled delivery
cost_amountnumberMessage cost
cost_currencystringCurrency code (e.g., SAR)
error_messagestring|nullError details if status is failed
created_atstringUTC datetime when the log was created

Message Status Values ​

StatusDescription
queuedWaiting in queue to be sent
scheduledScheduled for future delivery
sentAccepted by WhatsApp Cloud API
deliveredDelivered to the recipient's device
readRead by the recipient
failedDelivery failed — see error_message

Polling vs. Webhooks

Polling GET /api/v1/messages/{id} is useful for checking a specific message after the fact. For real-time updates, configure a webhook to receive message.status_updated events automatically.

CubeConnect WhatsApp Business Platform