You can use this method to send instant notifications to a list of users.

Pre-requisites

Triggering Broadcast

You can trigger broadcast using suprClient.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);
    }

Broadcast body field description:

ParameterDescription
list_idlist of users that you want to send broadcast messages to.
templateAdd template slug here. You can get this slug by clicking on the clipboard icon next to the Template name on SuprSend templates page. It is the same for all channels.
notification_categoryPreference Category to apply user preference settings while sending. Root categories - system / transactional / promotional
datavariable data defined in templates or workflow.
channelsSpecify 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
delayBroadcast will be halted for the time mentioned in delay, and become active once the delay period is over.
trigger_atTrigger broadcast on a specific date-time. Pass in ISO 8601 timestamp (eg. “2021-08-27T20:14:51.643Z”)
tenant_idid of the custom tenant to send broadcast for a specific tenant, used for applying tenant level customizations in notifications.
idempotency_keyunique 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.