# Creating Segments

Define rules to automatically group contacts.

Creating a segment in SendBeam takes only a few minutes. You give the segment a name, add one
or more rules, preview who matches, and save.

## Creating a new segment

Follow these steps to create your first segment:

1. Navigate to **Segments** in the left-hand sidebar. You will see a list of any
  existing segments with a summary of their rules. Click **New segment**, which
  opens the builder on a page of its own.
2. Enter a descriptive name in the name field. Good names make it clear who qualifies — for
  example, *Active UK subscribers* or *Acme staff*.
3. The form starts with one rule. Choose a field from the dropdown — a built-in field or
  **Custom field…**, which asks for the key — select an operator, and enter a
  value where required (*is empty* and *is not empty* take none). See
  [Operators & Fields](https://sendbeam.io/docs/segments/operators) for the full list.
4. Add additional rules as needed with **Add rule**, under the last rule. Remove a
  rule with the remove link beside it.
5. Watch the figure at the foot of the page. It keeps itself up to date as you change the
  rules — *Reachable now* is how many subscribed contacts the segment would reach today,
  and the number beside it is how many match in total. **Sample of who matches**
  opens a handful of them.
6. Save the segment. It is now available as an audience when creating a campaign.

> Use descriptive, consistent naming conventions across your segments. Prefixing names with a category — such as `geo:` or `lifecycle:` — makes them easier to scan when selecting an audience during campaign setup.
> 

## Combining rules

When a segment has more than one rule, **all rules must match** (AND). Each extra
rule narrows the audience. For example: status equals `subscribed` AND email ends
with `@acme.com`.

There is no OR option. If you need "A or B", create two segments and send the campaign twice,
once to each — or, where the two conditions can be expressed as one value, store that value in
a custom field and match on it.

> A rule with an empty value is ignored in previews, but the segment cannot be saved until every rule has a value (except *is empty* and *is not empty*, which take none).
> 

## Previewing matching contacts

As you build your segment, click the preview button to run the rules against your contacts.
The preview shows:

- The total number of matching contacts
- A sample of matching contacts with their names and email addresses

Preview and send use exactly the same rule evaluation, so the count you see is the audience a
campaign would resolve at that moment (before the status check that drops anyone who is not
Subscribed).

The same count is available from your own code through
`POST /api/v1/segments/preview`, which takes a set of rules without saving a
segment — handy for testing rules before creating one.

## Editing and deleting segments

To edit a segment:

1. Go to **Segments** in the sidebar.
2. Click the segment's name, or choose **Edit** from the menu at the end of its row. The builder opens pre-filled with its name and rules, and the count at the foot shows who it reaches today.
3. Change the name or rules — the count follows them — and save.

The same is possible from your own code with `PATCH /api/v1/segments/{id}`.

To delete a segment:

1. Open the segment, or choose **Delete** from the menu at the end of its row.
2. On the segment's own page, open **Delete this segment** at the foot and click **Delete segment**.
3. Confirm. Draft campaigns that used the segment as their audience will need a new audience before they can send.

Changes made through the API take effect immediately — the next time the segment is resolved,
at campaign send time, the updated rules are used. Campaigns reference the segment by its ID,
so renaming it does not affect them.

---
Source: https://sendbeam.io/docs/segments/creating
