Skip to main content

Documentation Index

Fetch the complete documentation index at: https://segmentflow.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Use broadcasts.create when your backend needs to create a one-time email campaign for a saved Segment. The route is POST /api/v1/broadcasts. It accepts a Resend-style payload with segmentId, from, subject, and html/text. Segmentflow creates a saved Email Template from the inline content, creates a Broadcast linked to the Segment, and returns the Broadcast id. You can also pass templateId to reuse an existing Segmentflow Email Template instead of inline content.
import { Segmentflow } from "@segmentflow/segmentflow-typescript";

const client = new Segmentflow({ apiKey: process.env.SEGMENTFLOW_API_KEY });

const draft = await client.v1.broadcasts.create({
  segmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  from: "Acme <news@example.com>",
  subject: "hello world",
  html: "Hi there, here is this week's update.",
});
Set send: true to start the Broadcast immediately. To schedule it, combine send: true with scheduledAt.
await client.v1.broadcasts.create({
  segmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  from: "Acme <news@example.com>",
  subject: "hello world",
  html: "Hi there, here is this week's update.",
  send: true,
  scheduledAt: "in 1 hour",
});
topicId maps to Segmentflow’s Email SubscriptionGroup id and is required before a Broadcast can be sent.