How do I send text, image, and template messages with the WhatsApp Business API?

How do I send text, image, and template messages with the WhatsApp Business API?

⚡Quick answer -

Send a POST request that contains these required fields:

  • waba_id (your WhatsApp Business Account ID)
  • phone_number_id
  • customer_country_code
  • customer_number
  • data (defines the message type and content)
  • myop_ref_id (your internal reference)

Use data.type = "text" or "image" for basic messages. For templates set data.type = "template", pass dynamic values in context.body, and (optionally) attach header.media_url after uploading the file via GET /chat/media/upload.

Watch for two critical errors: CHAT_0302 (WABA disabled) and 403 “Invalid company ID!”.

A successful call always returns:

Notes
{"status": "success", "code": "200", "message": "Message Sent"}

When should I use this guide?

Use this article whenever you need one place to copy-paste the exact JSON and field names for:

  1. Text messages
  2. Image messages
  3. Template messages (including media uploads and dynamic variables)



1. Prerequisites & Required IDs

Field

Why it matters

waba_id

The WhatsApp Business Account ID is used in all API calls

phone_number_id

The sender's phone number is registered in WhatsApp Manager

customer_country_code

ISO country code for the recipient

customer_number

The recipient’s phone number (without country code)

data

An object that holds the message type and content

myop_ref_id

Your internal reference for tracking




2. Core request template

{
"waba_id": "<YOUR_WABA_ID>",
"phone_number_id": "<YOUR_PHONE_NUMBER_ID>",
"customer_country_code": "<ISO_CODE>",
"customer_number": "<RECIPIENT_NUMBER_WITHOUT_COUNTRY_CODE>",
"myop_ref_id": "<YOUR_REFERENCE>",
"data": { /* see sections 3–5 */ }
}




3. Sending a Text Message

HTTP method: POST

{
"waba_id": "<YOUR_WABA_ID>",
"phone_number_id": "<YOUR_PHONE_NUMBER_ID>",
"customer_country_code": "1",
"customer_number": "5551234567",
"myop_ref_id": "order-98765",
"data": {
"type": "text",
"context": {
"body": "Hello! Your order has shipped."
}
}
}




4. Sending an Image Message

HTTP method: POST

{
"waba_id": "<YOUR_WABA_ID>",
"phone_number_id": "<YOUR_PHONE_NUMBER_ID>",
"customer_country_code": "1",
"customer_number": "5551234567",
"myop_ref_id": "order-98765",
"data": {
"type": "image",
"link": "https://example.com/tracking.png",
"filename": "tracking.png",
"caption": "Order #98765 status",
"mime_type": "image/png"
}
}

Required image-specific fields: link, filename, caption, mime_type.




5. Sending a Template Message

5.1 Determine required variables

Send the template once in a live-chat session; every placeholder you see is a variable you must supply.

HTTP method: POST

{
"waba_id": "<YOUR_WABA_ID>",
"phone_number_id": "<YOUR_PHONE_NUMBER_ID>",
"customer_country_code": "1",
"customer_number": "5551234567",
"myop_ref_id": "promo-2025",
"data": {
"type": "template",
"context": {
"body": ["{{1}}", "{{2}}"]
},
"header": {
"media_url": "<OPTIONAL_MEDIA_URL>"
}
}
}

  • Use the body array to pass dynamic values.
  • Add header.media_url only if the approved template header expects media.

5.2 Uploading Media for Templates

  • Method: GET
  • Endpoint: /chat/media/upload
  • Include required headers and the file as form-data.

5.3 Including a Media URL in the Template Header

Add this block inside data:

"header": {
"media_url": "https://example.com/image.png"
}




6. Listing All Templates for Your WABA

HTTP method: GET Endpoint: /chat/templates?waba_id=<YOUR_WABA_ID>




7. Replying to a specific message 

Add the reply_to field with the original message ID

"reply_to": "INCOMING_MESSAGE_ID"



8. Error codes

Code

Message

When it happens

CHAT_0302

WABA (WhatsApp Business Account) is Disabled

Any outbound call made while the account is disabled

403

"Invalid company ID!"

The company_id in the request does not exist or is inactive

Flip-side: A request will also fail if any prerequisite field is missing or if the referenced template is not approved.




9. When does this NOT work?

The request will fail if any required field (listed in the Prerequisites table) is missing or empty, or if the template you reference has not been approved.




Keywords - WhatsApp API, send text, send image, template message, waba_id, phone_number_id, media upload, message sent