Text Message
Text messages are the most basic message type. Use type: "text" page and include the text object with the field body.
Request Body
Section titled “Request Body”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "text", "text": { "body": "Halo, ini pesan dari Mahadata API!" }}Field text
Section titled “Field text”| Field | Type | Required | Description |
|---|---|---|---|
body | string | Yes | The text message content, maximum 4096 characters |
Complete Example
Section titled “Complete Example”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!" } }'import requests
url = "https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages"headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}payload = { "messaging_product": "whatsapp", "to": "6281234567890", "type": "text", "text": { "body": "Halo, ini pesan dari Mahadata API!" }}
response = requests.post(url, json=payload, headers=headers)print(response.json())const response = await fetch( 'https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ messaging_product: 'whatsapp', to: '6281234567890', type: 'text', text: { body: 'Halo, ini pesan dari Mahadata API!', }, }), });const data = await response.json();console.log(data);Response
Section titled “Response”{ "messaging_product": "whatsapp", "messages": [ { "id": "msg_f7a816e2-8397-11f0-8e34-010203040506" } ]}Webhook Statuses You Will Receive
Section titled “Webhook Statuses You Will Receive”After sending a text message, you will receive the following status webhooks in sequence:
message.status.sent— The message was successfully sent to the WhatsApp networkmessage.status.delivered— Message reached the recipient’s devicemessage.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.
Messages with Custom Properties
Section titled “Messages with Custom Properties”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" }}Dry-Run Mode (Test)
Section titled “Dry-Run Mode (Test)”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.