Skip to main content
Segment Lists are currently in beta. Share feedback on our Slack community or at support@suprsend.com.
A Segment List is a dynamic List whose membership is defined by a SQL query. You write SQL against the users and events data you already send to SuprSend, and the list auto-refreshes as your data changes. Also known as dynamic audiences or SQL segments in other tools. Define the criteria once, and the list stays in sync with your live user and event data. You can write the SQL yourself, or describe the segment in plain English and let the SuprSend Agent generate the query for you.

How it works

You write a SQL query that returns distinct_ids. SuprSend runs that query against your workspace’s users and events tables, and everyone the query returns becomes a member of the list. Commit a version, and the list is ready to power broadcasts and workflow triggers. Two tables are exposed to your SQL:
  • users — one row per user in your workspace, with distinct_id, channel arrays (email, phone, push), and your custom user properties as JSON.
  • events — one row per event you’ve sent to SuprSend, with event_name, distinct_id, requested_at, and the event payload as JSON.
Every commit creates a new immutable version of the segment. The current version is live; older versions stay in history and you can roll back to any of them from the dashboard. Rolling back creates a new version — the audit trail is preserved. Queries are scoped to your workspace by the API key on the request; there is no cross-workspace access.

Setting up a segment

1. Create the list

Go to Lists → New List. In the source picker, select Segment List.
Source picker showing Segment tile selected with a NEW badge
Enter a list_id, and optionally a name and description. The list_id is the stable identifier you’ll reference from the API and workflows.
Create list modal with list_id, name, and description fields

2. Write your SQL or generate it with AI

After the list is created, you land in the Segment Builder — a SQL editor on the left, a schema panel on the right, and a Generate with AI button in the toolbar. Write the SQL yourself using the reference below, or click Generate with AI and describe the segment in plain English.
Segment Builder with SQL editor, schema panel, and Generate with AI button
Segment SQL runs against two tables — users and events — using a PostgreSQL- and ClickHouse-compatible dialect.

Generate SQL with the SuprSend Agent

Click Generate with AI in the builder toolbar and describe the segment in plain English — e.g. “Growth-plan users in the US who placed 3+ orders in the last 60 days”. The Agent returns SQL plus a plain-English summary; click Use this SQL to insert it at the cursor, then edit as needed.
The Agent references your user and event schemas to figure out which properties to use — it never reads your actual user data or event payloads. For accurate SQL, link a JSON schema to each event and keep your user-property descriptions current on the Schema page. Always dry-run and inspect the sample rows before committing.

Available tables

One row per user in your workspace.

Query Recommendations

A few things to keep in mind for accurate, efficient queries:
  • Always return distinct_id. It’s how membership is resolved, so include it in your SELECT. Other columns still show up in the dry-run preview, but don’t affect who ends up in the list.
  • Select only the columns you need. Prefer named columns over SELECT * — it keeps the query fast and skips large JSON fields (like user_properties or the event payload) you don’t actually use.
  • Query only users and events. These are the only two tables available; references to anything else are rejected.
  • Match event names in uppercase. event_name is stored in caps, so filter with event_name = 'ORDER_PLACED', not 'order_placed' — a lowercase match returns no rows.
  • Mind JSON key casing. Keys are case-sensitive, so properties ->> 'Amount' isn’t the same as properties ->> 'amount'.
  • No need to scope by workspace. There’s no workspace_id column to set — a query only reads data from the workspace you’re building it in.

Supported SQL

The dialect is PostgreSQL- and ClickHouse-compatible. For every supported function and query feature — organized by category, each with syntax, arguments, and an example — see the Segment SQL reference.

Sample queries

Users on the enterprise plan in the US region
Users tagged as VIP (where tags is an array)
Users with atleast 1 active email channel
Users with lifetime value of $2,500 or more
Users whose subscription has 50 or more seats
Verified VIP users on the enterprise plan from selected countries

3. Dry-run to preview matched users

Click Run query (or press Cmd/Ctrl + Enter) to execute a dry-run. The dry-run panel shows the total count of matched users, the first 10 matched rows so you can spot-check the segment, and the exact error if the SQL is invalid. The two API calls under the hood:
Response for the sample-rows call:
200
Response for the count call:
200

4. Commit the segment

Committing makes your segment live and users start syncing into the list immediately. The first sync runs right after you commit, and the list keeps refreshing as your data changes. Each commit is stored as an immutable version, and any broadcast or workflow trigger that references this list uses the live version. You can commit without running a dry-run first, though it’s good practice to preview the matched users and confirm they look right before you do. Add an optional commit message describing what changed — e.g. “Expanded to 5 countries; 60-day order window.” — and confirm. The message shows up in Version History.
Commit modal with an optional commit message

Create a segment via the API

You can also create a Segment List directly through the API, with the SQL as the initial query. A segment created via the API is committed automatically — it goes live and starts syncing as soon as the request succeeds, with no separate commit step.
cURL
See Create a List for the full request/response contract.

5. Trigger notifications to the segment

Once the segment is committed, you can use it anywhere lists are supported.
Send the same notification to everyone in the segment — click Run Broadcast from the list’s details page, or trigger it via the API. SuprSend refreshes the segment right before sending, so it reaches the users who satisfy the filters at the time of sending.

Versioning and rollback

Every commit creates a new version. The current version is live; older versions stay in Version History on the list detail page. Open Version History to see every version and its SQL. To revert, pick an older version and click Rollback to this version — it becomes the new live version.
Version History panel with version list on the left and SQL, summary, and commit message on the right

Enable or disable a segment

A segment is enabled the moment you commit it. Toggle it off from the 3 dots menu on the list detail page — the segment stops refreshing but the query and version history stay intact, so you can turn it back on later. Existing memberships remain in place while disabled, so a manually-triggered broadcast can still send to the last-known members.

Troubleshooting

The dry-run couldn’t complete in the allowed time. Simplify: narrow the time window on events, add more selective filters, avoid SELECT with many columns, and add a LIMIT. Then re-run.
A red banner appears under the editor: “Missing distinct_id. Query results must include a distinct_id column to sync users to the list.” Commit is blocked until the SELECT is fixed.
Commit is allowed — the segment simply has no members until data changes and someone matches. The dashboard shows a 0 users matched indicator with a suggestion to adjust filters.
Extra columns show up in the dry-run preview so you can spot-check the data. They do not affect list membership — only distinct_id is used to sync users into the list.
Two common causes: (1) a column name in the Agent’s SQL doesn’t match your workspace’s schema — check the schema panel and correct the identifier; (2) the time window is too narrow. Adjust and re-run. The Agent uses your schema but it can still make plausible-looking mistakes.

Next steps

Send a Broadcast

Use a Segment List as the audience for a one-shot campaign.

Setup Workflow on List entry/exit

Trigger workflows when users enter or exit a segment.