Use the Broadcast API to create and send a broadcast with a single request.
Previously, to create and send a Broadcast via the API, it required two separate requests: one to create the Broadcast and another to send it.
Starting today, you can create and send a Broadcast with a single request.
When making the call, you can now set the send parameter to true to create and send a Broadcast with a single request.
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 {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}',send: true,});
If you create and send a Broadcast in a single call, you can also schedule the Broadcast for a future date. Use either natural language or a timestamp in ISO 8601 format.
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 {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}',send: true,scheduledAt: 'in 1 hour',});
We're excited to see how this functionality streamlines your Broadcast sending. For more information, check out the API reference for creating Broadcasts.