Segments

List segment memberships for context instance

POST
/api/v2/projects/{projectKey}/environments/{environmentKey}/segments/evaluate

For a given context instance with attributes, get membership details for all segments. In the request body, pass in the context instance.

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Path Parameters

projectKey*string

The project key

Formatstring
environmentKey*string

The environment key

Formatstring

Request Body

application/json

[key: string]?unknown

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/v2/projects/string/environments/string/segments/evaluate" \  -H "Content-Type: application/json" \  -d '{    "address": {      "city": "Springfield",      "street": "123 Main Street"    },    "jobFunction": "doctor",    "key": "context-key-123abc",    "kind": "user",    "name": "Sandy"  }'
{  "items": [    {      "name": "Segment Name",      "key": "segment-key-123abc",      "description": "Segment description",      "unbounded": false,      "external": "https://amplitude.com/myCohort",      "isMember": true,      "isIndividuallyTargeted": true,      "isRuleTargeted": false,      "_links": {        "property1": {          "href": "string",          "type": "string"        },        "property2": {          "href": "string",          "type": "string"        }      }    }  ],  "_links": {    "property1": {      "href": "string",      "type": "string"    },    "property2": {      "href": "string",      "type": "string"    }  }}

Patch holdout PATCH

Updates an existing holdout, and returns the updated holdout. Updating holdouts uses the semantic patch format. To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch). ### Instructions Semantic patch requests support the following `kind` instructions for updating holdouts. <details> <summary>Click to expand instructions for <strong>updating holdouts</strong></summary> #### endHoldout Ends a holdout. ##### Parameters None. Here's an example: ```json { "comment": "Optional comment describing why the holdout is ending", "instructions": [{ "kind": "endHoldout" }] } ``` #### removeExperiment Removes an experiment from a holdout. ##### Parameters - `value`: The key of the experiment to remove Here's an example: ```json { "comment": "Optional comment describing the change", "instructions": [{ "kind": "removeExperiment", "value": "experiment-key" }] } ``` #### updateDescription Updates the description of the holdout. ##### Parameters - `value`: The new description. Here's an example: ```json { "comment": "Optional comment describing the update", "instructions": [{ "kind": "updateDescription", "value": "Updated holdout description" }] } ``` #### updateName Updates the name of the holdout. ##### Parameters - `value`: The new name. Here's an example: ```json { "comment": "Optional comment describing the update", "instructions": [{ "kind": "updateName", "value": "Updated holdout name" }] } ``` </details>

List segments GET

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`.