Skip to main content
Creates a new broadcast based on the provided parameters. By default, broadcasts are created as drafts. You can optionally send them immediately or schedule them for later.

Methods

Create

Create(params *CreateBroadcastRequest) (CreateBroadcastResponse, error)
Creates a broadcast using the default background context.

CreateWithContext

CreateWithContext(ctx context.Context, params *CreateBroadcastRequest) (CreateBroadcastResponse, error)
Creates a broadcast with a custom context for cancellation and timeout control.

Request

segment_id
string
required
The ID of the segment to send the broadcast to.
from
string
required
The sender email address.
subject
string
required
The email subject line.
name
string
A name to identify the broadcast.
html
string
The HTML content of the email.
text
string
The plain text content of the email.
reply_to
string[]
An array of email addresses to set as reply-to addresses.
send
boolean
Set to true to send the broadcast immediately upon creation instead of creating a draft.
scheduled_at
string
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”). Only valid when send is true.
audience_id
string
deprecated
Deprecated. Use segment_id instead.

Response

id
string
The unique identifier for the created broadcast.

Example

package main

import (
    "fmt"
    "github.com/resend/resend-go/v2"
)

func main() {
    client := resend.NewClient("re_123456789")

    params := &resend.CreateBroadcastRequest{
        Name:      "Product Launch",
        SegmentId: "seg_123456",
        From:      "[email protected]",
        Subject:   "New Product Launch",
        Html:      "<h1>Check out our new product!</h1>",
        ReplyTo:   []string{"[email protected]"},
    }

    broadcast, err := client.Broadcasts.Create(params)
    if err != nil {
        panic(err)
    }

    fmt.Println("Broadcast ID:", broadcast.Id)
}

Example: Create and send immediately

params := &resend.CreateBroadcastRequest{
    Name:      "Newsletter",
    SegmentId: "seg_123456",
    From:      "[email protected]",
    Subject:   "Weekly Newsletter",
    Html:      "<h1>This week's updates</h1>",
    Send:      true,
}

broadcast, err := client.Broadcasts.Create(params)

Example: Create and schedule

params := &resend.CreateBroadcastRequest{
    Name:        "Scheduled Newsletter",
    SegmentId:   "seg_123456",
    From:        "[email protected]",
    Subject:     "Weekly Newsletter",
    Html:        "<h1>This week's updates</h1>",
    Send:        true,
    ScheduledAt: "2024-12-01T19:32:22.980Z",
}

broadcast, err := client.Broadcasts.Create(params)
At least one of html or text must be provided. Both segment_id (or deprecated audience_id) and from are required fields.

Build docs developers (and LLMs) love