Sending Text Messages
Use this api to send text messages.
API_TOKEN
Developers can authenticate their API calls with the API_TOKEN
generated in App Dashboard > Phone Numbers > Detail > Api
. To send a text message, make a POST
call to /messages
and attach a message object with type=contacts
.
Parameters
This is the main parameter used in send text message requests:
Name | Description |
---|---|
to | Required WhatsApp ID or phone number for the person you want to send a message to. The phone numbers in this requests can be provided in any dialable format, as long as they include their country code. It's recommended that you explicitly prefix the country code with a plus sign (+). Here are some examples of supported phone number formats:
|
reply_message_id | Optional You can send any message as a reply to a previous message in a conversation by including the previous message's ID. The recipient will receive the new message along with a contextual bubble that displays the previous message's content. |
type | Required The type of message you want to send. Set this as individual text . |
text | Required A text object. |
text.body | Required The text of the text message which can contain URLs which begin with http:// or https:// and formatting. If you include URLs in your text and want to include a preview box in text messages (preview_url: true), make sure the URL starts with http:// or https:// —https:// URLs are preferred. You must include a hostname, since IP addresses will not be matched. Maximum length: 4096 characters |
text.preview_url | Optional By default, WhatsApp recognizes URLs and makes them clickable, but you can also include a preview box with more information about the link. Set this field to true if you want to include a URL preview box. The majority of the time, the receiver will see a URL they can click on when you send an URL, set preview_url to true, and provide a body object with a http or https link. URL previews are only rendered after one of the following has happened:
Default: false . |
Example
Sample request:
curl -X POST 'https://waofficial.botika.online/api/whatsapp/v1/messages' \ -H 'Authorization: Bearer {{ API_TOKEN }}' \ -H 'Content-Type: application/json' \ -d '{ "to": "+62821xxxxxx", "reply_message_id": "{{ MESSAGE_ID }}", "type": "text", "text": { "body": "MESSAGE_CONTENT", "preview_url": false } }'
A successful response includes an object with an identifier for the message:
{ "data": { "id": "{{ MESSAGE_ID }}" } }