Pre-requisites
Triggering broadcast
You can trigger broadcast usingsuprClient.subscriberLists.broadcast() method.
import org.json.JSONObject;
import suprsend.Suprsend;
import suprsend.SuprsendAPIException;
import suprsend.SubscriberListBroadcast;
import suprsend.SuprsendValidationError;
public class Lists {
public static void main(String[] args) throws Exception {
broadcast();
}
private static Subscriber broadcast() throws SuprsendException {
Suprsend suprsendClient = new Suprsend("_workspace_key_", "_workspace_secret_");
// Create broadcast body
String listId = "_list_id_";
String templateSlug = "_template_slug_";
String notifCategory = "_preference_category_";
//Optional Fields
//String delay = "30";
//String triggerAt = "2023-03-06T18:56:51.643Z";
//ArrayList<String> channels = new ArrayList<>(Arrays.asList("androidpush","email"));
//String idempKey = "__unique_id_of_the_request__";
//String tenantId = "__tenant_id__";
JSONObject body = new JSONObject().put("list_id",listId)
.put("template",templateSlug)
.put("notification_category",notifCategory)
.put("data", new JSONObject()
.put("link_suffix", "https://s3.amazonaws.com/unroll-images-production/projects%2F22692%2F1630591176038-322170")
.put("first_name", "Joe"))
SubscriberListBroadcast broadcastIns = new SubscriberListBroadcast(body);
// Broadcast with idempotency key and brand id
// SubscriberListBroadcast broadcastIns = new SubscriberListBroadcast(body, idempKey, tenantId);
JSONObject res = suprClient.subscriberLists.broadcast(broadcastIns);
System.out.println(res);
}
import org.json.JSONObject;
import suprsend.Suprsend;
import suprsend.SuprsendAPIException;
import suprsend.SubscriberListBroadcast;
import suprsend.SuprsendValidationError;
public class Lists {
public static void main(String[] args) throws Exception {
broadcast();
}
private static Subscriber broadcast() throws SuprsendException {
Suprsend suprsendClient = new Suprsend("_workspace_key_", "_workspace_secret_");
String listId = "_product_updates_";
String templateSlug = "Newsletter";
String notifCategory = "promotional";
JSONObject body = new JSONObject().put("list_id",listId)
.put("template",templateSlug)
.put("notification_category",notifCategory)
.put("data", new JSONObject()
.put("link_suffix", "https://s3.amazonaws.com/unroll-images-production/projects%2F22692%2F1630591176038-322170")
.put("first_name", "Joe"))
SubscriberListBroadcast broadcastIns = new SubscriberListBroadcast(body);
JSONObject res = suprClient.subscriberLists.broadcast(broadcastIns);
System.out.println(res);
}
{
'success': True,
'status': 'success',
'status_code': 202,
'message': 'OK'
}
| Parameter | Description |
|---|---|
| list_id | list of users that you want to send broadcast messages to. |
| template | Add template slug here. You can get this slug by selecting the clipboard icon next to the Template name on SuprSend templates page. It is the same for all channels. |
| notification_category | Preference Category to apply user preference settings while sending. Root categories - system / transactional / promotional |
| data | variable data defined in templates or workflow. |
| channels | Specify channels if you don’t want to send notification of all live channels in the template. Available channel keys - email, sms, whatsapp, androidpush, iospush, ms_teams, slack, webpush |
| delay | Broadcast will be halted for the time mentioned in delay, and become active once the delay period is over. |
| trigger_at | Trigger broadcast on a specific date-time. Pass in ISO 8601 timestamp (for example “2021-08-27T20:14:51.643Z”) |
| tenant_id | id of the custom tenant to send broadcast for a specific tenant, used for applying tenant level customizations in notifications. |
| idempotency_key | unique identifier of the request. We’ll be returning idempotency_key in our outbound webhook response. You can use it to map notification statuses and replies in your system. |