Audiences and segments

Static lists of contacts, and filters over them that are always current.

A broadcast goes to an audience or a segment. Either way, only contacts who are subscribed, reached by the broadcast's topic and not on the suppression list get it.

Audiences

An audience is a list you manage: contacts are added and removed explicitly (a contact can be in any number of them).

const { :  } = await ...({ : "Beta testers" });
if () {
  await ...(., {
    : ["ada@example.com", "grace@example.com"],
  });
}

// Or when creating the contact.
await ...({ : "linus@example.com", : [?. ?? ""] });

Segments

A segment is a filter, evaluated every time it is used, so it always reflects your contacts as they are now. A filter matches all or any of its conditions, which can test:

Conditions can be grouped one level deep, up to 20 in all.

const { :  } = await ...({
  : "Pro customers outside beta",
  : {
    : 1,
    : "all",
    : [
      { : "property", : "plan", : "eq", : "pro" },
      { : "audience", : "not_in", : "aud_01k7c8m4q2f3e9v6t5r1n0p8yz" },
    ],
  },
});

// Who it matches right now.
const { :  } = await ...(?. ?? "");

The dashboard's Segments page builds filters with a live count of the contacts they match. An audience, topic or property a segment uses can't be deleted until the segment stops using it, and neither can an audience, segment or topic of a broadcast that hasn't finished.