> ## Documentation Index
> Fetch the complete documentation index at: https://docs.suprsend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send broadcast notifications with the Java SDK

> Use the SuprSend Java SDK to send broadcast notifications to a list of subscribers, with code examples for setting up the broadcast request and payload.

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

## Pre-requisites

* [Create a list of users](/docs/lists-java)

## Triggering broadcast

You can trigger broadcast using `suprClient.subscriberLists.broadcast()` method.

<CodeGroup>
  ```java Request theme={"system"}
  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);
      }
  ```

  ```java Sample theme={"system"}
  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);
      }
  ```

  ```java Response theme={"system"}
  {
    'success': True,
    'status': 'success',
    'status_code': 202,
    'message': 'OK'
  }
  ```
</CodeGroup>

Broadcast body field description:

| 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](/docs/tenants), 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.              |

***
