Sends a broadcast to your audience. You can send it immediately or schedule it for later.
Methods
Send
Send(params *SendBroadcastRequest) (SendBroadcastResponse, error)
Sends a broadcast using the default background context.
SendWithContext
SendWithContext(ctx context.Context, params *SendBroadcastRequest) (SendBroadcastResponse, error)
Sends a broadcast with a custom context for cancellation and timeout control.
Request
The ID of the broadcast to send.
Schedule the email to be sent later. Accepts natural language (e.g., “in 1 min”) or ISO 8601 format (e.g., “2024-08-05T11:52:01.858Z”).
Response
The unique identifier of the sent broadcast.
package main
import (
"fmt"
"github.com/resend/resend-go/v2"
)
func main() {
client := resend.NewClient("re_123456789")
params := &resend.SendBroadcastRequest{
BroadcastId: "brd_123456",
}
response, err := client.Broadcasts.Send(params)
if err != nil {
panic(err)
}
fmt.Println("Broadcast sent:", response.Id)
}
Example: Schedule for later
package main
import (
"fmt"
"github.com/resend/resend-go/v2"
)
func main() {
client := resend.NewClient("re_123456789")
params := &resend.SendBroadcastRequest{
BroadcastId: "brd_123456",
ScheduledAt: "2024-12-01T19:32:22.980Z",
}
response, err := client.Broadcasts.Send(params)
if err != nil {
panic(err)
}
fmt.Println("Broadcast scheduled:", response.Id)
}
Example: Schedule with natural language
params := &resend.SendBroadcastRequest{
BroadcastId: "brd_123456",
ScheduledAt: "in 1 hour",
}
response, err := client.Broadcasts.Send(params)
When scheduling a broadcast, you can use natural language like “in 1 min”, “in 2 hours”, or “tomorrow at 9am”, or provide an ISO 8601 formatted timestamp.
Make sure the broadcast is in draft status before sending. You cannot send a broadcast that has already been sent.