Send SMS Broadcast
Post
bash
https://api.bunce.so/v1/broadcast/send/sms
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
subject string required | Message Subject |
message string required | Broadcast Content |
all_customers boloean optional | Add this option to send message to all customers |
recipients array optional | Recipient array. Required if all_customers key is not present in the request or is false. Possible values for type customer segment |
schedule_type string required | Broadcast Schedule type. Possible values for type send-now send-later |
schedule_date array [ schedule_date: date; timezone: string; ] optional | Required if schedule type is send-later |
track_links boloean required | Set this option to true to track links |
include_unsubscribe_link boloean required | Set this option to true to include an unsubscribe link |
Recipients
The recipients
field is an array that is required if all_customer is not sent in the payload or if all_customers is set to false . Each recipient object should contain the following fields:
Field | Description |
---|---|
type string required | The type of recipient. Accepted values are customer and segment . |
customers array required if recipient type is customer |
|
A new customer record will be created for the customer object passed or updated if the customer email or customer_id already exist.
Devices Field
The devices
field is an optional array of device objects. Each device object should contain the following fields:
device_type
(string): The type of device (e.g.,ios
,android
).device_token
(string): The token associated with the device.
bash
curl --request POST \
--url https://api.bunce.so/v1/broadcast/send/sms \
--header 'Content-Type: application/json' \
--header 'X-Authorization: sk_live_************************' \
--data '{
"subject" : "Broadcast Test",
"message" : "This is a test SMS broadcast message",
"recipients": {
"type" : "customer",
"customers": [
{
"customer_id": "77345873453834",
"first_name": "Mfon New",
"last_name": "Robert New",
"email": "email38953664@gmail.com",
"phone_no" : "+2348062295588",
"devices":[{"device_type":"ios","device_token":"token_from_sms_broadcast-2-08ydjbjrb"}]
}
]
},
"schedule_type": "send-now",
"track_links": true,
"include_unsubscribe_link": true
}'
go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.bunce.so/v1/messaging/transactional/send/sms"
payload := strings.NewReader("{\n \"subject\": \"Broadcast Test\",\n \"message\": \"This is a test SMS broadcast message\",\n \"recipients\": {\n \"type\": \"customer\",\n \"customers\": [\n {\n \"customer_id\": \"77345873453834\",\n \"first_name\": \"Mfon New\",\n \"last_name\": \"Robert New\",\n \"email\": \"email38953664@gmail.com\",\n \"phone_no\": \"+2348062295588\",\n \"devices\": [\n {\n \"device_type\": \"ios\",\n \"device_token\": \"token_from_sms_broadcast-2-08ydjbjrb\"\n }\n ]\n }\n ]\n },\n \"schedule_type\": \"send-now\",\n \"track_links\": true,\n \"include_unsubscribe_link\": true\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 = ('node-fetch')
let = 'https://api.bunce.so/v1/broadcast/send/sms'
let = {
: 'POST',
: {
'X-Authorization': 'sk_live_************************',
'Content-Type': 'application/json',
},
: '{"subject":"Broadcast Test","message":"This is a test SMS broadcast message","recipients":{"type":"customer","customers":[{"customer_id":"77345873453834","first_name":"Mfon New","last_name":"Robert New","email":"email38953664@gmail.com","phone_no":"+2348062295588","devices":[{"device_type":"ios","device_token":"token_from_sms_broadcast-2-08ydjbjrb"}]}]},"schedule_type":"send-now","track_links":true,"include_unsubscribe_link":true}',
}
(, )
.then(() => .json())
.then(() => .())
.catch(() => .('error:' + ))
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"subject" : "Broadcast Test",
"message" : "This is a test SMS broadcast message",
"recipients": {
"type" : "customer",
"customers": [
{
"customer_id": "77345873453834",
"first_name": "Mfon New",
"last_name": "Robert New",
"email": "email38953664@gmail.com",
"phone_no" : "+2348062295588",
"devices":[{"device_type":"ios","device_token":"token_from_sms_broadcast-2-08ydjbjrb"}]
}
]
},
"schedule_type": "send-now",
"track_links": true,
"include_unsubscribe_link": true
}');
$request->setRequestUrl('https://api.bunce.so/v1/broadcast/send/sms');
$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/broadcast/send/sms"))
.header("X-Authorization", "sk_live_************************")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"subject\":\"Broadcast Test\",\"message\":\"This is a test SMS broadcast message\",\"recipients\":{\"type\":\"customer\",\"customers\":[{\"customer_id\":\"77345873453834\",\"first_name\":\"Mfon New\",\"last_name\":\"Robert New\",\"email\":\"email38953664@gmail.com\",\"phone_no\":\"+2348062295588\",\"devices\":[{\"device_type\":\"ios\",\"device_token\":\"token_from_sms_broadcast-2-08ydjbjrb\"}]}]},\"schedule_type\":\"send-now\",\"track_links\":true,\"include_unsubscribe_link\":true}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Response
json
{
"success": true,
"data": null,
"message": "SMS broadcast sent successfully"
}