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

Get segment

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

Get a single segment by key.

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.

Was this page helpful?
Previous

List segment memberships for context instance

Next
Built with

Authentication

Authorizationstring
API Key authentication via header

Path parameters

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

Response

Segment response
namestring

A human-friendly name for the segment.

tagslist of strings
Tags for the segment. Defaults to an empty array.
creationDatelong
Timestamp of when the segment was created
lastModifiedDatelong
Timestamp of when the segment was last modified
keystring
A unique key used to reference the segment
_linksmap from strings to objects
The location and content type of related resources
ruleslist of objects
An array of the targeting rules for this segment.
versioninteger
Version of the segment
deletedboolean
Whether the segment has been deleted
generationinteger
For big segments, how many times this segment has been created.
descriptionstring

A description of the segment’s purpose. Defaults to null and is omitted in the response if not provided.

includedlist of strings

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.

excludedlist of strings

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.

includedContextslist of objects
excludedContextslist of objects
_accessobject
_flagslist of objects

A list of flags targeting this segment. Only included when getting a single segment, using the getSegment endpoint.

unboundedboolean

Whether this 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. If omitted, the segment is a standard segment.

unboundedContextKindstring
For big segments, the targeted context kind.
_unboundedMetadataobject
Details on the external data store backing this segment. Only applies to big segments.
_externalstring
The external data store backing this segment. Only applies to synced segments.
_externalLinkstring
The URL for the external data store backing this segment. Only applies to synced segments.
_importInProgressboolean
Whether an import is currently in progress for the specified segment. Only applies to big segments.

Errors

401
Unauthorized Error
404
Not Found Error
429
Too Many Requests Error