whatsapp api send message

1 hour ago 2
Nature

You can send WhatsApp messages programmatically using the official WhatsApp Cloud API provided by Meta. Here is an overview of how to send a message via the WhatsApp API:

  • Use the WhatsApp Cloud API endpoint to send messages by making a POST request to the /messages endpoint of your WhatsApp Business Phone Number.

  • The request payload must specify the messaging_product as "whatsapp", the recipient's phone number in international format under the to field, and the message type and content.

  • For example, to send a text message, set "type": "text" and provide the message body inside the "text" object.

  • The API requires an authorization bearer token in the header for authentication.

  • A typical JSON payload for sending a text message looks like this:

    json

    { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "+16505551234", "type": "text", "text": { "preview_url": true, "body": "Here is the link to our latest product: https://www.meta.com/quest/quest-3/" } }

  • The API responds with a JSON confirming the request was accepted; actual delivery status is reported asynchronously via webhooks

Additionally, you can send media messages by first uploading media to WhatsApp, which remains accessible for 30 days, then referencing the media ID in your message request

. There are also third-party providers like Twilio and Green API that offer WhatsApp messaging APIs with additional features and ease of integration

. For quick testing or sending messages without a WhatsApp Business account, services like SMSMobileAPI allow sending WhatsApp messages via API without identity verification

. In summary, to send a WhatsApp message via API you need to:

  • Obtain access to the WhatsApp Business Cloud API.
  • Authenticate with a bearer token.
  • Construct a POST request to the /messages endpoint with the recipient number, message type, and content.
  • Handle delivery status via webhooks.

This method supports text, media, template messages, and more for business communication needs