Send Whatsapp Message
Post
bash
https://api.bunce.so/v1/messaging/transactional/send/whatsapp
Send
If successful, your response includes a message that your message has been sent successfully. If there is an error with any of the parameters, it will return a 422 HTTP status code with details in an error object.
Request
Body Parameters required
customer_id string nullable | Recipient Customer ID. Required if recipient email is not sent |
phone_no string required | Recipient phone number. Phone number should be international format. Required if customer does not already exist or does not have a phone number |
whatsapp_template_id string required | Message Template |
variables object optional | Template variables, only required when template has variables |
Variables Field
The variables
field is an object that contains the values of the variables in the message template. The keys of the object should match the variable names in the template.
For example, if the template message is Hello, {{name}}! Your account balance is {{balance}}
, the variables
would be: name
and balance
.
name string required | The value of the name variable in the template. |
balance string required | The value of the balance variable in the template. |
Note that the above example is just an example and the actual values of the variables will depend on the context of the message.
bash
curl --request POST \
--url https://api.bunce.so/v1/messaging/transactional/send/whatsapp \
--header 'Content-Type: application/json' \
--header 'X-Authorization: sk_live_************************' \
--data '{
"phone_no" : "+2349088798657",
"message_type" : "otp",
"message" : "Your OTP is 8893",
"customer_id": "uhviue98454309t3f",
"template_id" : "9834797493459"
}'
go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.bunce.so/v1/messaging/transactional/send/whatsapp"
payload := strings.NewReader("{\n \"phone_no\" : \"+2349088798657\",\n \"message_type\" : \"otp\",\n \"message\" : \"Your OTP is 8893\",\n \"customer_id\": \"uhviue98454309t3f\",\n \"template_id\" : \"9834797493459\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Authorization", "sk_live_************************")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
js
const = {
: 'POST',
: {
'X-Authorization': 'sk_live_************************',
'Content-Type': 'application/json',
},
: '{"phone_no":"+2349088798657","message_type":"otp","message":"Your OTP is 8893","customer_id":"uhviue98454309t3f","template_id":"9834797493459"}',
}
('https://api.bunce.so/v1/messaging/transactional/send/whatsapp', )
.(() => .())
.(() => .())
.(() => .())
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"phone_no" : "+2349088798657",
"message_type" : "otp",
"message" : "Your OTP is 8893",
"customer_id": "uhviue98454309t3f",
"template_id" : "9834797493459"
}');
$request->setRequestUrl('https://api.bunce.so/v1/messaging/transactional/send/whatsapp');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'X-Authorization' => 'sk_live_************************',
'Content-Type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
java
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.bunce.so/v1/messaging/transactional/send/whatsapp"))
.header("X-Authorization", "sk_live_************************")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"phone_no\" : \"+2349088798657\",\n \"message_type\" : \"otp\",\n \"message\" : \"Your OTP is 8893\",\n \"customer_id\": \"uhviue98454309t3f\",\n \"template_id\" : \"9834797493459\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Response
json
{
"success": true,
"data": null,
"message": "Whatsapp message sent successfully"
}