Send Text Message

Send a plain text WhatsApp message to a single recipient.

Scope: `send_text` | Method: `POST`
POST /api/v1/messages/send

Request Body

ParameterTypeRequiredDescription
tostringYesRecipient phone number with country code (e.g. `923001234567`)
messagestringYesThe body text content of the message
session_idstringNoOverrides the default assigned WhatsApp session

Example Request

curl -X POST "https://whatapi.pk/api/v1/messages/send" \
  -H "Authorization: Bearer whatapi_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "923001234567",
    "message": "Hello from Whatapi!"
  }'
fetch("https://whatapi.pk/api/v1/messages/send", {
  method: "POST",
  headers: {
    "Authorization": "Bearer whatapi_live_your_api_key_here",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    to: "923001234567",
    message: "Hello from Whatapi!"
  })
})
.then(res => res.json())
.then(data => console.log(data));

Response

{
  "success": true,
  "message_id": "gBGGK2Lx8K5X7J",
  "to": "923001234567",
  "session": "session-uuid",
  "timestamp": "2026-07-02T12:00:00.000Z"
}

Authorization Flow

  1. Extract API key from `Authorization: Bearer` header
  2. Look up key in Firestore `api_keys` collection
  3. Verify key is `active` and not expired
  4. Check key has `send_text` scope
  5. Check and decrement daily rate limit
  6. Resolve WhatsApp session (from `session_id` param or user's default)
  7. Send message via OpenWA backend
  8. Log the API call and increment counters