For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
    • Contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
      • POSTCreate big segment export
      • POSTCreate big segment import
      • POSTCreate segment
      • DELDelete segment
      • GETGet big segment export
      • GETGet big segment import
      • GETGet big segment membership for context
      • GETGet big segment membership for user
      • GETGet expiring targets for segment
      • GETGet expiring user targets for segment
      • GETGet segment
      • POSTList segment memberships for context instance
      • GETList segments
      • PATCHPatch segment
      • POSTUpdate context targets on a big segment
      • PATCHUpdate expiring targets for segment
      • PATCHUpdate expiring user targets for segment
      • POSTUpdate user context targets on a big segment
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewSegments

List segments

GET
/api/v2/segments/:projectKey/:environmentKey
GET
/api/v2/segments/:projectKey/:environmentKey
$curl https://app.launchdarkly.com/api/v2/segments/projectKey/environmentKey \
> -H "Authorization: <apiKey>"
1{
2 "items": [
3 {
4 "name": "Example segment",
5 "tags": [
6 "testing"
7 ],
8 "creationDate": 1654104600000,
9 "lastModifiedDate": 1654104600000,
10 "key": "segment-key-123abc",
11 "_links": {},
12 "rules": [
13 {
14 "clauses": [
15 {
16 "attribute": "email",
17 "op": "endsWith",
18 "values": [
19 ".edu"
20 ],
21 "negate": false,
22 "_id": "12ab3c45de678910fab12345"
23 }
24 ],
25 "_id": "1234a56b7c89d012345e678f"
26 }
27 ],
28 "version": 1,
29 "deleted": false,
30 "generation": 1,
31 "description": "Bundle our sample customers together",
32 "included": [
33 "user-key-123abc"
34 ],
35 "excluded": [
36 "user-key-123abc"
37 ],
38 "includedContexts": [
39 {
40 "values": [
41 "string"
42 ],
43 "contextKind": "string"
44 }
45 ],
46 "excludedContexts": [
47 {
48 "values": [
49 "string"
50 ],
51 "contextKind": "string"
52 }
53 ],
54 "_access": {
55 "denied": [
56 {
57 "action": "string",
58 "reason": {
59 "effect": "allow",
60 "resources": [
61 "proj/*:env/*;qa_*:/flag/*"
62 ],
63 "notResources": [
64 "string"
65 ],
66 "actions": [
67 "*"
68 ],
69 "notActions": [
70 "string"
71 ],
72 "role_name": "string"
73 }
74 }
75 ],
76 "allowed": [
77 {
78 "action": "string",
79 "reason": {
80 "effect": "allow",
81 "resources": [
82 "proj/*:env/*;qa_*:/flag/*"
83 ],
84 "notResources": [
85 "string"
86 ],
87 "actions": [
88 "*"
89 ],
90 "notActions": [
91 "string"
92 ],
93 "role_name": "string"
94 }
95 }
96 ]
97 },
98 "_flags": [
99 {
100 "name": "Example flag",
101 "key": "flag-key-123abc",
102 "_links": {},
103 "_site": {
104 "href": "string",
105 "type": "string"
106 }
107 }
108 ],
109 "unbounded": false,
110 "unboundedContextKind": "string",
111 "_unboundedMetadata": {
112 "envId": "string",
113 "segmentId": "string",
114 "version": 1,
115 "includedCount": 1,
116 "excludedCount": 1,
117 "lastModified": 1,
118 "deleted": true
119 },
120 "_external": "amplitude",
121 "_externalLink": "https://analytics.amplitude.com/org/1234/cohort/123abc",
122 "_importInProgress": false
123 }
124 ],
125 "_links": {},
126 "totalCount": 1
127}
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`.
Was this page helpful?
Previous

Patch segment

Next
Built with

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:

Field
DescriptionSupported operators
excludedKeysThe segment keys of segments to exclude from the results.anyOf
externalWhether the segment is a synced segment.exists
includedKeysThe segment keys of segments to include in the results.anyOf
queryA “fuzzy” search across segment key, name, and description. Supply a string or list of strings to the operator.equals
tagsThe segment tags.anyOf
unboundedWhether 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.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
environmentKeystringRequiredformat: "string"
The environment key

Query parameters

limitlongOptional
The number of segments to return. Defaults to 20.
offsetlongOptional

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.

sortstringOptionalformat: "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.

filterstringOptionalformat: "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

Segment collection response
itemslist of objects
An array of segments
_linksmap from strings to objects
The location and content type of related resources
totalCountinteger
The total number of segments

Errors

401
Unauthorized Error
404
Not Found Error