Sending Text Messages
Endpoint
To send a text message, make a POST
request to the following endpoint:
URL: /whatsapp/send-message
Request Headers
Include the API key as an Authorization
header using the Bearer token scheme.
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Request Body
The request body should contain the following parameters:
- phoneNumber (string, required): The recipient's phone number in international format (e.g., +254712345678).
- message (string, required): The message you want to send. You can include line breakers (\n) for formatting.
- type (string, required, value:text): The type of message, which should be set to text.
Example Request
- POST /whatsapp/send-message
- Authorization: Bearer YOUR_API_KEY
- Content-Type: application/json
{
"phoneNumber": "+254712345678",
"message": "Hello from the created instance!\nThis is a sample text message.",
"type": "text"
}
Successful Response
If the message is sent successfully, you will receive the following response:
{
"message": "Message sent successfully"
}
Error Responses
If there are any errors in the request, you will receive one of the following error responses:
- "Invalid phone number": The provided phone number is not in the correct international format.
- "Phone number not registered on WhatsApp": The recipient's phone number is not registered on WhatsApp.
- "Missing required inputs": One or more required parameters are missing in the request body.