---
title: "List segments"
method: GET
path: "/api/v2/segments/{projectKey}/{environmentKey}"
tags: ["Segments"]
---

# List segments

`GET /api/v2/segments/{projectKey}/{environmentKey}`

Get a list of all segments in the given project.

Segments can be rule-based, list-based, or synced. Big segments include larger list-based segments and synced segments. Some fields in the response only apply to big segments.

### Filtering segments

The `filter` parameter supports the following operators: `equals`, `anyOf`, and `exists`.

You can also combine filters in the following ways:

- Use a comma (`,`) as an AND operator
- Use a vertical bar (`|`) as an OR operator
- Use parentheses (`()`) to group filters

#### Supported fields and operators

You can only filter certain fields in segments when using the `filter` parameter. Additionally, you can only filter some fields with certain operators.

When you search for segments, the `filter` parameter supports the following fields and operators:

|<div style="width:120px">Field</div> |Description |Supported operators |
|---|---|---|
| `excludedKeys` | The segment keys of segments to exclude from the results. | `anyOf` |
| `external` | Whether the segment is a synced segment. | `exists` |
| `includedKeys` | The segment keys of segments to include in the results. | `anyOf` |
| `query` | A "fuzzy" search across segment key, name, and description. Supply a string or list of strings to the operator. | `equals` |
| `tags` | The segment tags. | `anyOf` |
| `unbounded` | Whether the segment is a standard segment (`false`) or a big segment (`true`). Standard segments include rule-based segments and smaller list-based segments. Big segments include larger list-based segments and synced segments. | `equals` |

Here are a few examples:

* The filter `?filter=tags anyOf ["enterprise", "beta"],query equals "toggle"` matches segments with "toggle" in their key, name, or description that also have "enterprise" or "beta" as a tag.
* The filter `?filter=excludedKeys anyOf ["segmentKey1", "segmentKey2"]` excludes the segments with those keys from the results.
* The filter `?filter=unbounded equals true` matches larger list-based segments and synced segments.

The documented values for `filter` query parameters are prior to URL encoding. For example, the `[` in `?filter=tags anyOf ["enterprise", "beta"]` must be encoded to `%5B`.

## Path parameters

- `projectKey` string, string, required — The project key
- `environmentKey` string, string, required — The environment key

## Query parameters

- `limit` integer — The number of segments to return. Defaults to 20.
- `offset` integer — Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query `limit`.
- `sort` string, string — Accepts sorting order and fields. Fields can be comma separated. Possible fields are 'creationDate', 'name', 'lastModified'. Example: `sort=name` sort by names ascending or `sort=-name,creationDate` sort by names descending and creationDate ascending.
- `filter` string, string — Accepts filter by `excludedKeys`, `external`, `includedKeys`, `query`, `tags`, `unbounded`, `view`. To learn more about the filter syntax, read the 'Filtering segments' section above.

## Response `200`

Segment collection response

- UserSegments
  - `items` UserSegment[], required — An array of segments
    - `name` string, required — A human-friendly name for the segment.
    - `description` string — A description of the segment's purpose. Defaults to <code>null</code> and is omitted in the response if not provided.
    - `tags` string[], required — Tags for the segment. Defaults to an empty array.
    - `creationDate` integer, required
    - `lastModifiedDate` integer, required
    - `key` string, required — A unique key used to reference the segment
    - `included` string[] — An array of keys for included targets. Included individual targets are always segment members, regardless of segment rules. For list-based segments over 15,000 entries, also called big segments, this array is either empty or omitted.
    - `excluded` string[] — An array of keys for excluded targets. Segment rules bypass individual excluded targets, so they will never be included based on rules. Excluded targets may still be included explicitly. This value is omitted for list-based segments over 15,000 entries, also called big segments.
    - `includedContexts` SegmentTarget[]
      - `values` string[]
      - `contextKind` string
    - `excludedContexts` SegmentTarget[]
      - `values` string[]
      - `contextKind` string
    - `_links` object, required — The location and content type of related resources
    - `rules` UserSegmentRule[], required — An array of the targeting rules for this segment.
      - `_id` string
      - `clauses` Clause[], required
        - `_id` string
        - `attribute` string, required
        - `op` string, required
        - `values` unknown[], required
          - unknown
        - `contextKind` string
        - `negate` boolean, required
      - `weight` integer
      - `rolloutContextKind` string
      - `bucketBy` string
      - `description` string
    - `version` integer, required — Version of the segment
    - `deleted` boolean, required — Whether the segment has been deleted
    - `_access` Access
      - `denied` AccessDenied[], required
        - `action` string, required
        - `reason` AccessDeniedReason, required
          - `resources` string[] — Resource specifier strings
          - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
          - `actions` ActionSpecifier[] — Actions to perform on a resource
          - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
          - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
          - `role_name` string
      - `allowed` AccessAllowedRep[], required
        - `action` string, required
        - `reason` AccessAllowedReason, required
          - `resources` string[] — Resource specifier strings
          - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
          - `actions` ActionSpecifier[] — Actions to perform on a resource
          - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
          - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
          - `role_name` string
    - `_flags` FlagListingRep[] — A list of flags targeting this segment. Only included when getting a single segment, using the <code>getSegment</code> endpoint.
      - `name` string, required — The flag name
      - `key` string, required — The flag key
      - `_links` object
      - `_site` Link
        - `href` string
        - `type` string
    - `unbounded` boolean — Whether this is a standard segment (<code>false</code>) or a big segment (<code>true</code>). Standard segments include rule-based segments and smaller list-based segments. Big segments include larger list-based segments and synced segments. If omitted, the segment is a standard segment.
    - `unboundedContextKind` string — For big segments, the targeted context kind.
    - `generation` integer, required — For big segments, how many times this segment has been created.
    - `_unboundedMetadata` SegmentMetadata
      - `envId` string
      - `segmentId` string
      - `version` integer
      - `includedCount` integer
      - `excludedCount` integer
      - `lastModified` integer
      - `deleted` boolean
    - `_external` string — The external data store backing this segment. Only applies to synced segments.
    - `_externalLink` string — The URL for the external data store backing this segment. Only applies to synced segments.
    - `_importInProgress` boolean — Whether an import is currently in progress for the specified segment. Only applies to big segments.
  - `_links` object, required — The location and content type of related resources
  - `totalCount` integer — The total number of segments

## Other responses

- `401` — Invalid access token
- `404` — Invalid resource identifier

---

[API](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api.md) · [All operations](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/launchdarkly/launchdarkly-rest-api/revisions/69c5c9aafe78/schema)
