Skip to content

Text Message

Text messages are the most basic message type. Use type: "text" page and include the text object with the field body.

{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "text",
"text": {
"body": "Halo, ini pesan dari Mahadata API!"
}
}
FieldTypeRequiredDescription
bodystringYesThe text message content, maximum 4096 characters
Terminal window
curl -X POST https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "text",
"text": {
"body": "Halo, ini pesan dari Mahadata API!"
}
}'
{
"messaging_product": "whatsapp",
"messages": [
{
"id": "msg_f7a816e2-8397-11f0-8e34-010203040506"
}
]
}

After sending a text message, you will receive the following status webhooks in sequence:

  1. message.status.sent — The message was successfully sent to the WhatsApp network
  2. message.status.delivered — Message reached the recipient’s device
  3. message.status.read — The message was read by the recipient (if read receipts are supported)

If delivery fails, you will receive message.status.failed with the failure reason.

See the page Webhook for details on the payload format of each event.

You can include custom metadata that will be returned in the webhook but not sent to the recipient:

{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "text",
"text": {
"body": "Pesan dengan tracking metadata"
},
"custom_properties": {
"division_id": "DIV001",
"branch_code": "JKT-001"
}
}

To validate a request without actually sending a message (no charge incurred), add the field test:

{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "text",
"text": {
"body": "Pesan test"
},
"test": true
}

The API will validate authentication, template, pricing, and balance, but will not send the message. The response 200 OK page with a diagnostic body.