SDK
Segments
Group contacts dynamically with filter-based segments.
Segments let you define reusable filters over your contact list — useful for targeting specific audiences.
Create a segment
const segment = await connect.segment.create({
name: "Email subscribers",
description: "Contacts with an email address",
criteria: {
hasEmail: true,
},
});Filter criteria
| Field | Type | Description |
|---|---|---|
query | string | Free-text search across name, email, phone |
hasEmail | boolean | Only contacts with an email |
hasPhone | boolean | Only contacts with a phone number |
tags | string[] | Contacts that have all specified tags |
await connect.segment.create({
name: "VIP SMS users",
criteria: {
hasPhone: true,
tags: ["vip"],
},
});List segments
const { items } = await connect.segment.list({
limit: 20,
offset: 0,
});Get a segment
const segment = await connect.segment.get({ id: "seg_..." });Update a segment
await connect.segment.update({
id: "seg_...",
name: "Active VIPs",
criteria: {
hasEmail: true,
tags: ["vip", "active"],
},
});Delete a segment
await connect.segment.delete({ id: "seg_..." });