---
title: "Segments"
description: "Reusable audiences that rules in any environment can target."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Segments

A **segment** is a reusable audience in a project, shared by every environment: `beta-testers`,
`staff`. Rules target it with `segmentMatch` or `notSegmentMatch`.

A context is in a segment when:

- its `targetingKey` is **included** (up to 10,000), or it matches any of the segment's **rules**
  (each rule's clauses are ANDed; rules are ORed), and
- its `targetingKey` isn't **excluded** (up to 10,000).

Segment rules use the same operators as [flag rules](/flags/targeting#rules), except the segment
operators: segments don't nest.

Changing a segment changes every flag that uses it, in every environment. A change that would make
an environment's flags too large is refused ([Limits](/flags/limits)). A segment a flag's
targeting uses can't be deleted (`409 segment_in_use`, naming the flags and environments).

```sh
ezgh flags segments create beta-testers --include user-7 --include user-9
ezgh flags segments update beta-testers --rules-file rules.json
```

`rules.json` is a list of rules:

```json
[
  { "clauses": [{ "attribute": "email", "operator": "endsWith", "values": ["@acme.com"] }] }
]
```

Source: https://docs.ezghcloud.com/flags/segments/index.mdx
