Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Managing Segments

Segments are used to group and manage your Contacts. Segments are not visible to your Contacts, but are used for your own internal Contact organization.

Segments were designed to be used in conjunction with Broadcasts. You can send a Broadcast to an Segment from the Resend dashboard or from the Broadcast API.

You can send emails to your Segment by creating a new Broadcast and selecting the Segment you want to send it to.

Send emails to your Segment

You can include the Unsubscribe Footer in your Broadcasts, which will be automatically replaced with the correct link for each Contact.

You can also use our Broadcast API to create and send a Broadcast to your Segment.

Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.broadcasts.create({
  segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf',
  from: 'Acme <onboarding@resend.dev>',
  subject: 'hello world',
  html: 'Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}',
});
PHP
$resend = Resend::client('re_xxxxxxxxx');

$resend->broadcasts->create([
  'segment_id' => '78261eea-8f8b-4381-83c6-79fa7120f1cf',
  'from' => 'Acme <onboarding@resend.dev>',
  'subject' => 'hello world',
  'html' => 'Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}',
]);
Python
import resend

resend.api_key = "re_xxxxxxxxx"

params: resend.Broadcasts.CreateParams = {
  "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  "from": "Acme <onboarding@resend.dev>",
  "subject": "Hello, world!",
  "html": "Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}",
}

resend.Broadcasts.create(params)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

params = {
  "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  "from": "Acme <onboarding@resend.dev>",
  "subject": "hello world",
  "html": "Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}",
}
Resend::Broadcasts.create(params)
Go
import "github.com/resend/resend-go/v4"

client := resend.NewClient("re_xxxxxxxxx")

params := &resend.CreateBroadcastRequest{
  SegmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  From:       "Acme <onboarding@resend.dev>",
  Html:       "Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}",
  Subject:    "Hello, world!",
}

client.Broadcasts.Create(params)
Rust
use resend_rs::{types::CreateBroadcastOptions, Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let segment_id = "78261eea-8f8b-4381-83c6-79fa7120f1cf";
  let from = "Acme <onboarding@resend.dev>";
  let subject = "hello world";
  let html = "Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}";

  let opts = CreateBroadcastOptions::new(segment_id, from, subject).with_html(html);

  let _broadcast = resend.broadcasts.create(opts).await?;

  Ok(())
}
Java
import com.resend.*;
import com.resend.services.broadcasts.model.CreateBroadcastOptions;
import com.resend.services.broadcasts.model.CreateBroadcastResponseSuccess;

Resend resend = new Resend("re_xxxxxxxxx");

CreateBroadcastOptions params = CreateBroadcastOptions.builder()
    .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf")
    .from("Acme <onboarding@resend.dev>")
    .subject("hello world")
    .html("Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}")
    .build();

CreateBroadcastResponseSuccess data = resend.broadcasts().create(params);
.NET
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

var resp = await resend.BroadcastAddAsync(
    new BroadcastData()
    {
        DisplayName = "Example Broadcast",
        SegmentId = new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ),
        From = "Acme <onboarding@resend.dev>",
        Subject = "Hello, world!",
        HtmlBody = "Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}",
    }
);
Console.WriteLine( "Broadcast Id={0}", resp.Content );
cURL
curl -X POST 'https://api.resend.com/broadcasts' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  "from": "Acme <onboarding@resend.dev>",
  "subject": "hello world",
  "html": "Hi {{{contact.first_name|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}"
}'
Section titled “How to customize the unsubscribe link in my Broadcast”

Resend generates a unique link for each recipient and each Broadcast. You can use {{{RESEND_UNSUBSCRIBE_URL}}} as the link target.

Unsubscribe Link

When you send emails to your Segment, Resend will automatically handle the unsubscribe flow for you.

Automatic Unsubscribes

If a Contact unsubscribes from your emails, they will be presented with a preference page.

  • If you don't have any Topics configured, the Contact will be unsubscribed from all emails from your account.
  • If you have Topics configured, the Contact will be presented with a preference page where they can subscribe or unsubscribe from specific types of emails (all public Topics will be shown).

Learn more about managing your unsubscribe list or customizing your unsubscribe page.

Admins can download your data in CSV format for the following resources:

  • Emails
  • Broadcasts
  • Contacts
  • Segments
  • Domains
  • Logs
  • API keys

To start, apply filters to your data and click on the "Export" button. Confirm your filters before exporting your data.

Video

If your exported data includes 1,000 items or less, the export will download immediately. For larger exports, you'll receive an email with a link to download your data.

All admins on your team can securely access the export for 7 days. Unavailable exports are marked as "Expired."

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu