Email Broadcasts
Relevant source files
The following files were used as context for generating this wiki page:
- src/main/java/com/resend/services/broadcasts/Broadcasts.java
- src/main/java/com/resend/services/broadcasts/model/Broadcast.java
- src/main/java/com/resend/services/broadcasts/model/BroadcastOptions.java
- src/test/java/com/resend/services/broadcasts/BroadcastsTest.java
- src/test/java/com/resend/services/util/BroadcastsUtil.java
The Email Broadcasts module manages the lifecycle of bulk email communications sent to specific audiences or segments. You use this service to create, update, schedule, and track emails sent to multiple recipients simultaneously. It integrates with the Resend API to handle large-scale delivery and provides detailed analytics on recipient engagement.
Sources: Broadcasts.java:12-14, BroadcastsUtil.java:8-16
Broadcast Lifecycle and Operations
The Broadcasts service provides methods to manage broadcast states from initial draft through to delivery and post-send analysis.
Service Architecture
The Broadcasts class extends BaseService and interacts with the Resend API through an IHttpClient. It maps Java objects to JSON payloads for API requests.
The diagram shows how the Broadcasts service acts as a gateway between the client application and the Resend REST API.
Sources: Broadcasts.java:17-31, Broadcasts.java:140-143
Key Management Functions
| Operation | Method | Description |
|---|---|---|
| Create | create(CreateBroadcastOptions) | Initializes a new broadcast draft with content and target segment. |
| Retrieve | get(String id) | Fetches the full details and current status of a specific broadcast. |
| Update | update(UpdateBroadcastOptions) | Modifies the content, subject, or settings of an existing draft. |
| Send | send(SendBroadcastOptions, String) | Triggers immediate or scheduled delivery of a broadcast. |
| Duplicate | duplicate(String id) | Creates a new draft based on an existing broadcast. |
| Cancel | cancel(String id) | Stops a queued or scheduled broadcast before delivery occurs. |
Sources: Broadcasts.java:39-106, Broadcasts.java:138-145
Data Models
Broadcast Configuration
The BroadcastOptions and its subclasses define the structure of a broadcast.
| Field | Type | Description |
|---|---|---|
name | String | Internal name for the broadcast. |
subject | String | The email subject line. |
from | String | The sender's email address. |
segment_id | String | The unique identifier of the recipient segment. |
audience_id | String | (Deprecated) Target audience identifier. |
html | String | The HTML content of the email. |
text | String | The plain text fallback content. |
reply_to | List | List of email addresses for recipient replies. |
Sources: BroadcastOptions.java:12-34, BroadcastOptions.java:160-230
Broadcast Object
The Broadcast model represents the state of a broadcast returned by the API.
This class diagram illustrates the metadata and delivery timestamps tracked for every broadcast.
Sources: Broadcast.java:8-27
Recipient Tracking and Engagement
The system allows you to monitor how recipients interact with a broadcast through specific event types.
Event Tracking Flow
This sequence shows the process of retrieving recipient-level engagement data.
Sources: Broadcasts.java:115-118, BroadcastsTest.java:232-250
Supported Analytics
You can filter recipients based on their interaction status using the BroadcastRecipientEventType enum:
- SENT: Recipients to whom the broadcast was successfully dispatched.
- OPENED: Recipients who opened the email (includes open count).
- CLICKED: Recipients who clicked links (includes specific URL tracking).
- BOUNCED: Failed deliveries (includes bounce type, such as "permanent").
Sources: BroadcastsTest.java:232-280, Broadcasts.java:115-118
Click Analysis
The clickedLinks method provides aggregated data on link performance within a broadcast, including total clicks and unique clicks per URL.
Sources: Broadcasts.java:127-130, BroadcastsTest.java:199-210
Summary
The Email Broadcasts module provides a structured Java interface for the Resend Broadcasts API. It enables developers to manage complex bulk email workflows, including drafting content with BroadcastOptions, controlling delivery states (sent, scheduled, or cancelled), and performing deep analysis of recipient engagement through event-based tracking and link click metrics.
Sources: Broadcasts.java:12-16, Broadcast.java:54-85